Example usage for com.amazonaws.services.cognitoidp.model AuthenticationResultType getIdToken

List of usage examples for com.amazonaws.services.cognitoidp.model AuthenticationResultType getIdToken

Introduction

In this page you can find the example usage for com.amazonaws.services.cognitoidp.model AuthenticationResultType getIdToken.

Prototype


public String getIdToken() 

Source Link

Document

The ID token.

Usage

From source file:io.fineo.client.auth.cognito.CognitoUser.java

License:Open Source License

/**
 * Creates a user session with the tokens from authentication and overrider the refresh token
 * with the value passed./*from w  w w.  java  2 s .c om*/
 *
 * @param authResult                        REQUIRED: Authentication result which contains the
 *                                          tokens.
 * @param refreshTokenOverride              REQUIRED: This will be used to create a new session
 *                                          object if it is not null.
 * @return {@link CognitoUserSession} with the latest tokens.
 */
private CognitoUserSession getCognitoUserSession(AuthenticationResultType authResult,
        CognitoRefreshToken refreshTokenOverride) {
    String idtoken = authResult.getIdToken();
    CognitoIdToken idToken = new CognitoIdToken(idtoken);

    String acctoken = authResult.getAccessToken();
    CognitoAccessToken accessToken = new CognitoAccessToken(acctoken);

    CognitoRefreshToken refreshToken;

    if (refreshTokenOverride != null) {
        refreshToken = refreshTokenOverride;
    } else {
        String reftoken = authResult.getRefreshToken();
        refreshToken = new CognitoRefreshToken(reftoken);
    }
    return new CognitoUserSession(idToken, accessToken, refreshToken);
}