Implicit Flow

The implicit grant type is used to obtain access tokens (it does not support the issuance of refresh tokens) and is optimized for public clients known to operate a particular redirection URI. These clients are typically implemented in a browser using a scripting language such as JavaScript.

More Details https://tools.ietf.org/html/rfc6749#section-4.2

How to Use in PHP

1) Create App in Cidaas

To work with implicit flow we need to create Browser based application in cidaas app section

2) Get Access Token

In this example I am going to use Cidaas/oauth2-cidaas-php . for more library please visit https://oauth.net/code/


$provider = new Cidaas([
    'baseUrl'                 => 'yourcidaasbaseurl',
    'clientId'                => 'xxxx',    // The client ID assigned to you by the provider
    'clientSecret'            => 'yyyy',   // The client password assigned to you by the provider
    'redirectUri'             => 'https://yourredirecturl'
]);

print_r($provider->getAuthorizationUrl(["response_type"=>'token']));
print_r("\n");

This code will give you the autherization url. redirect to the browser with this URL. Once the User logged in to the account , cidaas will redirect to the redirect_uri with the hash of access_token and expire_in

Example:

http://localhost:8080#access_token=eyJ...&expires_in=86400&viewtype=login

3) Get User info

Once you got the access_token pass the access_token to cidaas user info url.

echo "Copy Paste the above URL in the browser and login and Enter the Access Token : ";
$handle = fopen ("php://stdin","r");
$line = fgets($handle);

$accessToken2 = new AccessToken(["access_token" => trim($line)]);
$resourceOwner = $provider->getResourceOwner($accessToken2);

print_r($resourceOwner);
User info format
{
  "id": "id",
  "provider": "Provider",
  "ssoId": "ssoid",
  "username": "vimalprakashts@gmail.com",
  "email": "vimalprakashts@gmail.com",
  "mobile": "+919738122401",
  "firstname": "vimal",
  "lastname": "prakash",
  "displayName": "vimal prakash",
  "createTime": 1476957466236,
  "active": true,
  "emailVerified": true,
  "mobileNoVerified": false,
  "smsNotificationEnabled": false,
  "googleAuthenticatorEnabled": false,
  "currentLocale": "en_US",
  "userStatus": "VERIFIED",
  "identityJRString": null,
  "customFields": {
    "groupid": "",
    "Title": "",
    "Gender": "",
    "DateofBirth": "",
    "Salutation": ""
  },
  "roles": [
    "USER"
  ],
  "twofactorenabled": false,
  "lastLoggedTime": 1500231552247,
  "lastUsedSocialIdentity": null,
  "photoURL": null,
  "usedProviders": null,
  "customFieldWithMetadata": {
    "groupid": {
      "dataType": "Text",
      "value": "",
      "internal": true,
      "readOnly": false
    },
    "Title": {
      "dataType": "Text",
      "value": "",
      "internal": true,
      "readOnly": false
    },
    "Gender": {
      "dataType": "Text",
      "value": "",
      "internal": true,
      "readOnly": false
    },
    "DateofBirth": {
      "dataType": "Text",
      "value": "",
      "internal": true,
      "readOnly": false
    },
    "Salutation": {
      "dataType": "Text",
      "value": "",
      "internal": true,
      "readOnly": false
    }
  },
  "groups": null
}



results matching ""

    No results matching ""