Skip to content

NPE thrown when token response contains a null value #8108

Closed
@bbruyn

Description

@bbruyn

Summary

I have to process a token response containing a null value for the scope key, which fails with a NullPointerException.

Actual Behavior

It looks like a recent change to OAuth2AccessTokenResponseHttpMessageConverter can cause a NPE to be thrown when the token response contains a null value.

Expected Behavior

I'm not sure why the provider includes the key with no value, but I don't believe it's invalid usage... It seems reasonable to support it.

Sample

This response

{
    "access_token": "bigfataccesstokenvalue",
    "expires_in": 3600,
    "token_type": "Bearer",
    "scope": null,
    "refresh_token": "bigfatrefreshtoken"
}

fails at getValue().toString

return this.tokenResponseConverter.convert(
					tokenResponseParameters.entrySet().stream()
							.collect(Collectors.toMap(
									Map.Entry::getKey,
									entry -> entry.getValue().toString())));

FWIW, I've just worked around it with a copy/paste implementation that uses String.valueOf instead.

return this.tokenResponseConverter.convert(
                    tokenResponseParameters.entrySet().stream()
                            .collect(Collectors.toMap(
                                    Map.Entry::getKey,
                                    entry -> String.valueOf(entry.getValue() ))));

Metadata

Metadata

Assignees

Labels

in: oauth2An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions