Parsing response from code authentication: Scope returned as array parsing exception.

Issue #461 invalid
Sindre Sjøstrand Brurberg created an issue

I might be doing something wrong, but I am trying to authenticate with a provider that returnes the scope as follows.

,"scope":["openid"],"token_type":"bearer"}

Which gives the following error.

com.nimbusds.oauth2.sdk.ParseException: Unexpected type of JSON object member with key scope

I am currently using the following function.

TokenResponse tr = OIDCTokenResponseParser.parse(response);

As the client can take multiple scopes when creating the initial request, I would assume that the response should also be able to handle multiple scopes?

If further code or information is wanted, then I can provide that.

Comments (4)

  1. Yavor Vasilev

    Ouch. You’re not doing anything wrong. The provider returns the scope as a JSON array, which is not the standard format for this situation.

    The scope must be a single space separated string, just like in the authZ request parameter. You may want to share the OAuth 2.0 RFC with the provider’s maintainers:

    https://datatracker.ietf.org/doc/html/rfc6749#section-3.3

    In the meantime, you may tweak the HTTPResponse body to get it in the correct format. Then it will parse okay.

  2. Log in to comment