<?php /** * Simple example showing how to use Accela CivicID for OAuth. */ // Include required files. require '../src/CivicID.php'; // Settings for OAuth. $redirect_uri = ''; $app_id = ''; $app_secret = ''; $environment = ''; $agency_name = ''; // Create a new CivicID object. $auth = new CivicID($app_id, $app_secret, $environment, $agency_name, Scopes::$civicid, $redirect_uri); // If first visit, redirect to CivicID login. if (!$_GET) { echo '<a href="' . $auth->getAuthorizationURL() . '">Log in with Accela CivicID.'; } else { // When Authorization Code is received, use it to request Access Token. $code = $_GET['code']; $response = $auth->getAccessToken($code); $auth_object = json_decode($response); $token = $auth_object->access_token; echo $token; }
<?php /** * Simple example showing how to use password credentials to obtain an auth token. */ // Include required files. require '../src/CivicID.php'; $app_id = ''; $app_secret = ''; $environment = ''; $agency_name = ''; $userid = ''; $password = ''; // Create a new CivicID object. $auth = new CivicID($app_id, $app_secret, $environment, $agency_name, 'records'); // Request a token with user id and password. $response = $auth->getTokenWithPassword($userid, $password); // Write out the new token. echo $response->access_token;