@Test public void loadCredential() throws Exception { OAuth2Credentials oAuth2Credentials = new OAuth2Credentials.Builder() .setClientSecrets("CLIENT_ID", "CLIENT_SECRET") .setRedirectUri("http: .setHttpTransport(mockHttpTransport) .setScopes(Arrays.asList(Scope.PROFILE, Scope.REQUEST)) .build(); oAuth2Credentials.authenticate("authorizationCode", "userId"); Credential credential = oAuth2Credentials.loadCredential("userId"); assertEquals("Refresh token does not match.", "refreshToken", credential.getRefreshToken()); assertTrue("Expected expires_in between 0 and 3600. Was actually: " + credential.getExpiresInSeconds(), credential.getExpiresInSeconds() > 0 && credential.getExpiresInSeconds() <= 3600); assertEquals("Access token does not match.", "accessToken", credential.getAccessToken()); assertEquals("Access method (Bearer) does not match", BearerToken.authorizationHeaderAccessMethod().getClass(), credential.getMethod().getClass()); }
public Credential loadCredential(String userId) throws AuthException { try { return authorizationCodeFlow.loadCredential(userId); } catch (IOException e) { throw new AuthException("Unable to load credential.", e); } }
OAuth2Credentials { public Credential loadCredential(String userId) throws AuthException { try { return authorizationCodeFlow.loadCredential(userId); } catch (IOException e) { throw new AuthException("Unable to load credential.", e); } } }
OAuth2Credentials { public Credential loadCredential(String userId) throws AuthException { try { return authorizationCodeFlow.loadCredential(userId); } catch (IOException e) { throw new AuthException("Unable to load credential.", e); } } private  OAuth2Credentials(); }
OAuth2Credentials { public Credential loadCredential(String userId) throws AuthException { try { return authorizationCodeFlow.loadCredential(userId); } catch (IOException e) { throw new AuthException("Unable to load credential.", e); } } private  OAuth2Credentials(); @Nullable String getAuthorizationUrl(); AuthorizationCodeFlow getAuthorizationCodeFlow(); Credential authenticate(String authorizationCode, String userId); Credential loadCredential(String userId); void clearCredential(String userId); String getRedirectUri(); }
OAuth2Credentials { public Credential loadCredential(String userId) throws AuthException { try { return authorizationCodeFlow.loadCredential(userId); } catch (IOException e) { throw new AuthException("Unable to load credential.", e); } } private  OAuth2Credentials(); @Nullable String getAuthorizationUrl(); AuthorizationCodeFlow getAuthorizationCodeFlow(); Credential authenticate(String authorizationCode, String userId); Credential loadCredential(String userId); void clearCredential(String userId); String getRedirectUri(); static final String AUTHORIZATION_PATH; static final String TOKEN_PATH; }