@Override protected void addAccessTokenToProfile(final U profile, final OAuth1AccessToken accessToken) { if (profile != null) { final String token = accessToken.getToken(); logger.debug("add access_token: {} to profile", token); profile.setAccessToken(token); profile.setAccessSecret(accessToken.getTokenSecret()); } }
static public OAuthRequest getRequestForProvider( final String providerName, final Verb httpVerb, final OAuth1AccessToken oa1token, final URL url, final HashMap<String,Object> cfg, @Nullable final ReadableMap params ) { final OAuth10aService service = OAuthManagerProviders.getApiFor10aProvider(providerName, cfg, null, null); String token = oa1token.getToken(); OAuthConfig config = service.getConfig(); OAuthRequest request = new OAuthRequest(httpVerb, url.toString(), config); request = OAuthManagerProviders.addParametersToRequest(request, token, params); // Nothing special for Twitter return request; }
@Override public void onReceivedAccessToken(Token accessToken, String oAuthVersion) { if (oAuthVersion == OAUTH1_VERSION) { OAuth1AccessToken oAuth1AccessToken = (OAuth1AccessToken) accessToken; client.setAccessToken(accessToken); editor.putString(OAuthConstants.TOKEN, oAuth1AccessToken.getToken()); editor.putString(OAuthConstants.TOKEN_SECRET, oAuth1AccessToken.getTokenSecret()); editor.putInt(OAuthConstants.VERSION, 1); editor.commit(); } else if (oAuthVersion == OAUTH2_VERSION) { OAuth2AccessToken oAuth2AccessToken = (OAuth2AccessToken) accessToken; client.setAccessToken(accessToken); editor.putString(OAuthConstants.TOKEN, oAuth2AccessToken.getAccessToken()); editor.putString(OAuthConstants.SCOPE, oAuth2AccessToken.getScope()); editor.putString(OAuthConstants.REFRESH_TOKEN, oAuth2AccessToken.getRefreshToken()); editor.putInt(OAuthConstants.VERSION, 2); editor.commit(); } accessHandler.onLoginSuccess(); }
@Override protected void signRequest(final OAuth10aService service, final OAuth1AccessToken token, final OAuthRequest request) { service.signRequest(token, request); if (this.configuration.isTokenAsHeader()) { request.addHeader("Authorization", "Bearer " + token.getToken()); } } }
credentials.putString("access_token", accessToken.getToken()); credentials.putString("access_token_secret", oauthTokenSecret); credentials.putString("type", tokenType);