Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Visit the URL http://localhost:8080/playground2/oauth2.jsp to start the scenario with the sample application.
  2. Enter the following details and click Authorize.

    Note

    Note: To try out this scenario with different consent values, see step 7.


  3. Provide user credentials and sign in with the previously created user.

  4. Click Approve to provide consent to this action. The screen mentions the service provider by name and requests for user consent to provide user information to that particular service provider. The user can either 
    1. Deny to provide information to the service provider.
    2. Approve to provide user profile information to this service provider only for this time.
    3. Approve Always to provide approval to share user profile information with the service provider even in the future without prompting for consent again.

    Tip

    Tip: After approval is provided, the application receives an authorization code issued from WSO2 Identity Server. This authorization code can only be used once to get a valid access token and has a expiry time that can be configured by editing the following property in the <IS_HOME>/repository/conf/identity/identity.xml file. The default expiry time is 300 seconds.

    Code Block
    languagexml
    <!-- Default validity period for Authorization Code in seconds -->
            <AuthorizationCodeDefaultValidityPeriod>300</AuthorizationCodeDefaultValidityPeriod>
  5. Enter the following details in the form that appears and click Get Access Token

  6. At this point, the application receives the Access Token with the id token, which follows the format shown in step 7. Enter the UserInfo endpoint of the WSO2 Identity Server, (i.e., https://localhost:9443/oauth2/userinfo), in the form as seen below, to get user information.

    Since the received access token has the scope 'openid', the userinfo endpoint provides the user attribute details when the request is made. You will receive the following response from the Identity Server.

    Code Block
    languagegroovy
    titleResponse
    {  
       "scope":"openid",
       "token_type":"Bearer",
       "expires_in":3600,
       "refresh_token":"74d0d7e6d4b3c19484f5135593c2dc88",   		  "id_token":"eyJhbGciOiJSUzI1NiJ9.eyJhdXRoX3RpbWUiOjE0NTIxNzAxNzYsImV4cCI6MTQ1MjE3Mzc3Niwic3ViIjoidXNlQGNhcmJvbi5zdXBlciIsImF6cCI6IjF5TDFfZnpuekdZdXRYNWdCMDNMNnRYR3lqZ2EiLCJhdF9oYXNoIjoiWWljbDFlNTI5WlhZOE9zVDlvM3ktdyIsImF1ZCI6WyIxeUwxX2Z6bnpHWXV0WDVnQjAzTDZ0WEd5amdhIl0sImlzcyI6Imh0dHBzOlwvXC9sb2NhbGhvc3Q6OTQ0M1wvb2F1dGgyXC90b2tlbiIsImlhdCI6MTQ1MjE3MDE3Nn0.RqAgm0ybe7tQYvQYi7uqEtzWf6wgDv5sJq2UIQRC4OJGjn_fTqftIWerZc7rIMRYXi7jzuHxX_GabUhuj7m1iRzi1wgxbI9yQn825lDVF4Lt9DMUTBfKLk81KIy6uB_ECtyxumoX3372yRgC7R56_L_hAElflgBsclEUwEH9psE",
       "access_token":"f1824ef345f0565ab88a06a51db98d24"
    }

    The returned ID token carries the user details. It follows the following format: <header>.<body>.<signature>. The decoded ID token can be seen below.

    Code Block
    languagegroovy
    titleDecoded ID Token
    {"alg":"RS256"}.
    {  
       "auth_time":1452170176,
       "exp":1452173776,
       "sub":"use@carbon.super",
       "azp":"1yL1_fznzGYutX5gB03L6tXGyjga",
       "at_hash":"Yicl1e529ZXY8OsT9o3y-w",
       "aud":[  
          "1yL1_fznzGYutX5gB03L6tXGyjga"
       ],
       "iss":"https:\/\/localhost:9443\/oauth2\/token",
       "iat":1452170176
    }.<signature value>
     
    Tip

    Tip: Alternatively, you can get user information by running the following cURL command on the terminal.

    Localtabgroup
    Localtab
    activetrue
    titlecURL Command
    Code Block
    languagepowershell
    curl -k -H "Authorization: Bearer <Acess_token>" https://localhost:9443/oauth2/userinfo?schema=openid
    Localtab
    titleResponse
    Code Block
    languagegroovy
    {  
       "sub":"admin",
       "email":"admin@wso2.com",
       "website":"https://wso2.com",
       "name":"admin",
       "family_name":"admin",
       "preferred_username":"admin",
       "given_name":"admin",
       "profile":"https://wso2.com",
       "country":"Sri Lanka"
    }
  7. You can also try out this scenario with different consent values {none, login and consent}. To do this, try the following URLs when entering the Authorization Endpoint URL in step 2 of the Try out scenario section. 

    Authorization Endpoint URLDescription
    https://localhost:9443/oauth2/authorize?prompt=none
     -
    The Identity Server does not display any authentication or consent user interface pages. An error is returned if an end user is not already authenticated or the client does not have pre-configured consent for the requested claims or if there are any other unfulfilled conditions for processing the request.
    https://localhost:9443/oauth2/authorize?prompt=login
     -
    Even if the end user is already authenticated, it will prompt the end user for re-authentication.
    https://localhost:9443/oauth2/authorize?prompt=consent
     - Even
    Even if the consent is already given, it will prompt the end user for consent again before returning information to the Client.
     
    Note

    Note: To completely skip user consent, you can also edit the following property in the <IS_HOME>/repository/conf/identity/identity.xml file. To skip user consent, set this property to true.

    Code Block
    languagexml
     <OpenIDSkipUserConsent>false</OpenIDSkipUserConsent>
    Warning

    Warning: Note that if this property is set to true, even if you use an Authorization Endpoint URL that prompts user consent (e.g.,https://localhost:9443/oauth2/authorize?prompt=consent), it will not prompt consent.