Search code examples
oauth-2.0salesforce

Enabling custom attributes (claims) for Salesforce connected app OAuth


I am trying to configure OAuth via a connected app in my Salesforce instance. I am able to login, but I do not get an custom claims (Custom Attributes). I think what I need is to check the "Include Custom Attributes" checkbox. But when I edit the app, that checkbox is no where to be checked. I can only see it in the view.

enter image description here

I am able to check a similar box under "Configure ID Token", but that checkbox seems to have no effect on the OAuth setting.

enter image description here

In the end, I just need to see my claims show up in my remote app. But I just get name and email.


Solution

  • When you make initial call to /services/oauth2/authorize - what's your response_type? For example is it token+id_token?

    You receive authorisation code valid for few minutes and then you swap it for the final response with access_token (a.k.a. SF session id), instance_url (endpoint to use from now on) etc.

    Custom attributes will be included in the base64-encoded id_token - if you requested it.

    And have you defined some custom attributes? They should be on related list at the bottom of the connected app's page but check that they exist in both places. There's the main app page (where you define OAuth2 scopes, can read the key & secret) - and there's the button to Manage Policies or sth like that (where you define which profiles/permission sets can use it) - custom attributes must be present on both pages' related lists.