I am trying to get a token for multiple scopes by calling springframework RestTemplate.exchange(…)
Headers anmd body are set properly, everything looks similar to the http request from Postman console, with
in request body (the 2 scopes are separated by a space).
Problem is that I get error
400 Bad Request: [{“error”:“invalid_scope”,“error_description”:“One or more scopes are not configured for the authorization server resource.”}]
when I call RestTemplate.exchange.
Is this an Okta authorization server you are using and if so is it the Org authorization server or a custom authorization server?
If it is the Org authorization server you can not create custom scopes such as the 2 you are using.
If it is a custom authorization server you need to make sure the authorization server has created those scopes and a proper access policy and rule allows it. To do this in Okta see Create an Authorization Server | Okta Developer
Thank you Eric.
The token creation works for both scopes from Postman.
The token URL looks like this:
https://{companyName}.oktapreview.com/oauth2/aus9z8gdpBh8yPTUC1d6/v1/token
My attempt is to generate the token through an http request programmatically, similar to what Postman does (and that works).
The issue may be related to the passing of the 2 scopes in the “scope” body variable.
I tried space, comma and even surrounded with double quotes, like these: