Skip to content
Closed
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
add idToken from token response
  • Loading branch information
esalem committed Feb 7, 2018
commit b584b6336b549cbaf8db4a35c2c81c758d2d4238
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ public interface AccessMethod {
/** Access token issued by the authorization server. */
private String accessToken;

/** Id token issued by the authorization server. */
private String idToken;

/**
* Expected expiration time in milliseconds based on {@link #setExpiresInSeconds} or {@code null}
* for none.
Expand Down Expand Up @@ -316,6 +319,36 @@ public Credential setAccessToken(String accessToken) {
return this;
}

/** Returns the id token or {@code null} for none. */
public final String getIdToken() {
lock.lock();
try {
return idToken;
} finally {
lock.unlock();
}
}

/**
* Sets the access token.
*
* <p>
* Overriding is only supported for the purpose of calling the super implementation and changing
* the return type, but nothing else.
* </p>
*
* @param idToken id token or {@code null} for none
*/
public Credential setIdToken(String idToken) {
lock.lock();
try {
this.idToken = idToken;
} finally {
lock.unlock();
}
return this;
}

/**
* Return the method of presenting the access token to the resource server (for example
* {@link BearerToken.AuthorizationHeaderAccessMethod}).
Expand Down Expand Up @@ -534,6 +567,7 @@ public final boolean refreshToken() throws IOException {
*/
public Credential setFromTokenResponse(TokenResponse tokenResponse) {
setAccessToken(tokenResponse.getAccessToken());
setIdToken(tokenResponse.getIdToken());
// handle case of having a refresh token previous, but no refresh token in current
// response
if (tokenResponse.getRefreshToken() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public class TokenResponse extends GenericJson {
/** Access token issued by the authorization server. */
@Key("access_token")
private String accessToken;

/** ID token issued by the authorization server. */
@Key("id_token")
private String idToken;

/**
* Token type (as specified in <a href="http://tools.ietf.org/html/rfc6749#section-7.1">Access
Expand Down Expand Up @@ -68,7 +72,7 @@ public class TokenResponse extends GenericJson {
public final String getAccessToken() {
return accessToken;
}

/**
* Sets the access token issued by the authorization server.
*
Expand All @@ -82,6 +86,24 @@ public TokenResponse setAccessToken(String accessToken) {
return this;
}

/** Returns the id token issued by the authorization server. */
public String getIdToken() {
return idToken;
}

/**
* Sets the id token issued by the authorization server.
*
* <p>
* Overriding is only supported for the purpose of calling the super implementation and changing
* the return type, but nothing else.
* </p>
*/
public TokenResponse setIdToken( String idToken ) {
this.idToken = Preconditions.checkNotNull(idToken);
return this;
}

/**
* Returns the token type (as specified in <a
* href="http://tools.ietf.org/html/rfc6749#section-7.1">Access Token Types</a>).
Expand Down