<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
0D51Y00007w98iWSAQOkta Classic EngineAdministrationAnswered2024-04-15T09:30:27.000Z2020-03-02T22:42:47.000Z2020-03-03T15:47:55.000Z

xc0g8 (xc0g8) asked a question.

Changing value of claim based on scope for service app

Hello.

 

I have created a custom auth server and a client_credentials app (without any user).

 

I want to create a claim with name say "custom_claim" and set its value based on requested scope by client.

 

For example:

Return value of "custom_claim" as "value1" if the scope is "scope1"

Return value of "custom_claim" as "value2" if the scope is "scope2"

 

I tried following the Expression Language overview page, but couldn't find any way to do this. https://developer.okta.com/docs/reference/okta-expression-language/

 

Have people done this for client_credentials based app where there is no user? I could have achieved this easily if it was a user based app, but can't figure out a way to do this for a service app.


  • bc221 (bc221)

    Hi Shirish,

     

    Is "value1" for scope is "scope1" is static value or dynamic ? what expression you tried if you are expecting dynamic value?

  • xc0g8 (xc0g8)

    @Vipul, the values are static, so I can hardcode them.

     

    I want something like:

     

    if(scope == "scope1") return "value1" else return "value2"

  • bc221 (bc221)

    Well that is very simple. Create a new Claim as mentioned below and Include claim only for The following scopes:

     

    So when you generate a token with "read" scope, Okta will add that static claim "Shirish_Claim" : "VALUE_1" in claim.

     

    Image is not available

    Expand Post
  • xc0g8 (xc0g8)

    @Vipul, your suggestion works when there is only one value. The problem is, you can't create claims with same name which are resolved in different scopes.

     

    Image is not available

    Expand Post
  • bc221 (bc221)

    I understand that.

     

    The solution you are looking for is not possible because Okta expression only derived attribute's value from universal directory and app profile. It cannot read scope.

This question is closed.
Loading
Changing value of claim based on scope for service app