I’m trying to get a custom scope returned in the access token that our Angular app requests. The Angular app is using version 3.0.1 of @okta/okta-angular.
I’ve configured a custom scope and set this scope in the rule used by the Access Policy.
We’re using the default custom authorization server.
When I test in the TokenPreview tab the access token looks fine (i.e., the custom scope is present), however, the Angular app does not return the custom scope in the access token. I’m configuring okta-angular as follows:
Still no joy - interestingly the following 3 scopes always return in the access token: openid, email, profile (I guess these are default scopes returned), but still can’t get the custom scope to be returned.
@ajmg How did you setup your custom scopes in Okta configuration, do you have a screenshot?
Also, in your code, how do you retrieve token? Here is a simple way.
I then added the custom scope to the rule in the Access Policy for the Angular app. There’s also appears to be a default access policy so I added the scope to that too.
I think we’re retrieving the token in the same way demonstrated in your link, i.e.,
@ajmg Can you show me the page of the scope list?
Click Security → API → Authorization Server → default auth sever → Scopes.
Also, the reason you see the 3 scopes (openid, email, profile) always returned is they are set as default which means It will be returned in an access token when the client omits the scope parameter in a token request.
If you are good to test, try to select metadata and default boxes for your customized scope and see if this scope is returned with the other three.
At the bottom of the link you referred to previously it says that to get custom scopes in token you need to refresh the idToken which will mint a new token with all scope attributes. Would this be correct - and also does that mean that the scope would be in the idToken rather than the access token? I’ve tried amending the code but methods are not recognised so perhaps this comment is referring to a different version of okta-angular?
@ajmg It sounds like the 3 default scopes are set as default in your code. In order to help you review the code, could you please open a support ticket through an email to support@okta.com. One of our dev support engineers will help.