<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
0D50Z00008G7VBzSANOkta Classic EngineIntegrationsAnswered2024-04-30T09:18:25.000Z2016-12-05T22:57:31.000Z2019-06-25T09:23:07.000Z
Include custom attributes in OpenId Connect id_token?
Hi,

 

How could I add custom user profile attributes in the id_token returned by the Okta OpenId Connect authentication? Is there a way to define custom scopes that would return one or several user profile attributes associated with those scopes?

 

Thank you,

 

Ricardo

  • RicardoM.75313 (Customer)

    Ok, I am going to go ahead and aswer my own question here, in case someone else runs into the same scenario.

     

    If you add a custom field to an application user profile, it will be automatically added to the id_token if the "profile" scope is requested. It is is that simple.

     

    However, I have not found a way to define a custom scope that would return only a subser of the custom fields defined. But that is not a show stopper for me.

    Expand Post
  • j5v7c (j5v7c)

    Hi Ricardo,

     

    You are correct that you cannot add custom scopes with our OpendID Connect implementation. You will need to get access to our API Access Management (https://www.okta.com/blog/2016/08/api-access-management/) product which is currently in beta. You can sign up to be part of the beta for that new product at https://oktabeta.zendesk.com (https://oktabeta.zendesk.com) if that is of interest to you.
    Expand Post
  • EwanC.59401 (Customer)

    Hi Raphael,

     

    Can you clarify a bit? Are you saying that the access token will not contain claims that we setup when using OpenId Connect?

     

    I can get them with the OAuth ResourceOwner Flow.
  • bl199 (bl199)

    Hi,

    I am generating access token using ${baseUrl}/v1/token, can i include some custom data(not specific to okta) in access token for authorization purpose or is there any other api which would be helpful?

  • bl199 (bl199)

    Thanks Dragos,

    Actually my requirement is different, I am already generating an access token for example this eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

    and i want to add my payload like {key1: value1, key2: value2}(not related to okta) into this access token via some update api. Can i do this?

    Expand Post
  • RAJANR.76759 (Customer)

    Hi Dragos,

     

    In our case we don't want to use API access management as we have custom roles defined in our data store. In this case, is it possible to add these roles to access token?

     

    Thanks,

    Rajan R.G

    Expand Post
  • Hi Rajan,

     

    Yes, you can add the attributes under Admin >> Directory >> Profile Editor >> OpenID app >> Profile. Once the attributes are added and you created a mapping for them from Okta user profile and/or modified the user's app assignment to have values for this attributes, please do a request to /oauth2/v1/authorize, specifying "openid" and "profile" as scopes.

     

    If you are requesting both ID token and access token (eg. response_type=id_token%20token or response_type=code), then the ID token is automatically minified and you can see this attributes by doing a second request to /userinfo endpoint, as mentioned here.

     

    Thank You,

     

    Dragos Gaftoneanu

    Developer Support Engineer

    Okta Global Customer Care

    Expand Post
  • RAJANR.76759 (Customer)

    Hi Dragos,

     

    Thanks for your quick response. As I mentioned, we would like to use our own data store for fine grained access control. In this case, can i add the roles from our database to the existing access token? Eg: we are planning to use lambda authorizer like https://github.com/tom-smith-okta/node-lambda-oauth2-jwt-authorizer/tree/tsmith/update. Once the access token is valid, we wanted to extend this custom authorizer to get the roles from our datastore and add to the existing token. Is this feasible?

     

    Thanks,

    Rajan R.G

    Expand Post
10 of 13
This question is closed.
Loading
Include custom attributes in OpenId Connect id_token?