OAuth2Credentials { public void clearCredential(String userId) throws AuthException { try { authorizationCodeFlow.getCredentialDataStore().delete(userId); } catch (IOException e) { throw new AuthException("Unable to clear 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; }
@Test public void clearCredential() 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"); assertNotNull(credential); oAuth2Credentials.clearCredential("userId"); credential = oAuth2Credentials.loadCredential("userId"); assertNull(credential); }