Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/main/java/org/dmfs/oauth2/client/tokens/JsonAccessToken.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ public Optional<CharSequence> extraParameter(final String parameterName)
return new NullSafe<>(mTokenResponse.optString(parameterName, null));
}

/**
* Returns the raw token response given by OAuth provider.
*
* @return An {@link org.json.JSONObject}.
*
*/
public JSONObject rawResponse()
{
return new JSONObject(mTokenResponse.toMap());
}

/**
* A {@link Function} which converts a String into an {@link OAuth2Scope}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ public void testCustomPayload() throws Exception
.extraParameter("idToken"), is(present(Matchers.<CharSequence>hasToString("id_token_value"))));
}

@Test
public void testRawResponse() throws Exception
{
JSONObject originalJsonObject = new JSONObject("{\"idToken\":\"id_token_value\"}");
assertThat(new JsonAccessToken(originalJsonObject, dummy(OAuth2Scope.class))
.rawResponse(), is(originalJsonObject)));
}



@Test
public void testCustomPayloadWithNonExistingParameter() throws Exception
Expand Down