• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java OAuthGetAccessToken类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.api.client.auth.oauth.OAuthGetAccessToken的典型用法代码示例。如果您正苦于以下问题:Java OAuthGetAccessToken类的具体用法?Java OAuthGetAccessToken怎么用?Java OAuthGetAccessToken使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



OAuthGetAccessToken类属于com.google.api.client.auth.oauth包,在下文中一共展示了OAuthGetAccessToken类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: new10aTokenRequest

import com.google.api.client.auth.oauth.OAuthGetAccessToken; //导入依赖的package包/类
/**
 * Returns a new instance of a token request based on the given verifier
 * code. This step is defined in <a
 * href="http://oauth.net/core/1.0a/#auth_step3">Obtaining an Access
 * Token</a>.
 * 
 * @param temporaryCredentials
 * @param verifierCode
 * @return
 */
public OAuthGetAccessToken new10aTokenRequest(OAuthCredentialsResponse temporaryCredentials,
        String verifierCode) {
    OAuthGetAccessToken request = new OAuthGetAccessToken(getTokenServerEncodedUrl());
    request.temporaryToken = temporaryCredentials.token;
    request.transport = getTransport();

    OAuthHmacSigner signer = new OAuthHmacSigner();
    ClientParametersAuthentication clientAuthentication = (ClientParametersAuthentication) getClientAuthentication();
    signer.clientSharedSecret = clientAuthentication.getClientSecret();
    signer.tokenSharedSecret = temporaryCredentials.tokenSecret;

    request.signer = signer;
    request.consumerKey = clientAuthentication.getClientId();
    request.verifier = verifierCode;
    return request;
}
 
开发者ID:agilie,项目名称:dribbble-android-sdk,代码行数:27,代码来源:AuthorizationFlow.java


示例2: obtainAccessToken

import com.google.api.client.auth.oauth.OAuthGetAccessToken; //导入依赖的package包/类
@NotNull
public static GitLabToken obtainAccessToken(@NotNull String gitlabUrl, @NotNull String username, @NotNull String password, boolean sudoScope) throws IOException {
  try {
    final OAuthGetAccessToken tokenServerUrl = new OAuthGetAccessToken(gitlabUrl + "/oauth/token" + (sudoScope ? "?scope=api%20sudo" : ""));
    final TokenResponse oauthResponse = new PasswordTokenRequest(transport, JacksonFactory.getDefaultInstance(), tokenServerUrl, username, password).execute();
    return new GitLabToken(TokenType.ACCESS_TOKEN, oauthResponse.getAccessToken());
  } catch (TokenResponseException e) {
    if (sudoScope && e.getStatusCode() == HttpURLConnection.HTTP_UNAUTHORIZED) {
      // Fallback for pre-10.2 gitlab versions
      final GitlabSession session = GitlabAPI.connect(gitlabUrl, username, password);
      return new GitLabToken(TokenType.PRIVATE_TOKEN, session.getPrivateToken());
    } else {
      throw new GitlabAPIException(e.getMessage(), e.getStatusCode(), e);
    }
  }
}
 
开发者ID:bozaro,项目名称:git-as-svn,代码行数:17,代码来源:GitLabContext.java


示例3: doInBackground

import com.google.api.client.auth.oauth.OAuthGetAccessToken; //导入依赖的package包/类
@Override
protected Void doInBackground(Uri... params) {

    Log.i(TAG, "doInbackground called with url " + url);
    if (url.startsWith(Constants.OAUTH_CALLBACK_URL) && !handled) {
        try {

            if (url.indexOf("oauth_token=") != -1) {
                handled = true;
                String requestToken = extractParamFromUrl(url, "oauth_token");
                String verifier = extractParamFromUrl(url, "oauth_verifier");

                OAuthGetAccessToken accessToken = getOAuthAccessToken(requestToken);
                accessToken.verifier = verifier;

                OAuthCredentialsResponse credentials = accessToken.execute();
                signer.tokenSharedSecret = credentials.tokenSecret;

                LocalCredentialStore localStore = new LocalCredentialStore(prefs);
                localStore.store(new AuthToken(credentials.token, credentials.tokenSecret));

            } else if (url.indexOf("error=") != -1) {
                new LocalCredentialStore(prefs).clear();
            }

        } catch (IOException e) {
            Log.e(TAG, e.getMessage(), e);
        }

    }
    return null;
}
 
开发者ID:ipragmatech,项目名称:OAuth-Magento-Rest-Api-Retrofit,代码行数:33,代码来源:WebActivity.java


示例4: getOAuthAccessToken

import com.google.api.client.auth.oauth.OAuthGetAccessToken; //导入依赖的package包/类
public OAuthGetAccessToken getOAuthAccessToken(String requestToken) {
    signer.clientSharedSecret = Constants.CONSUMER_SECRET;
    OAuthGetAccessToken accessToken = new OAuthGetAccessToken(Constants.ACCESS_URL);
    accessToken.transport = new ApacheHttpTransport();
    accessToken.temporaryToken = requestToken;
    accessToken.signer = signer;
    accessToken.consumerKey = Constants.CONSUMER_KEY;
    return accessToken;
}
 
开发者ID:ipragmatech,项目名称:OAuth-Magento-Rest-Api-Retrofit,代码行数:10,代码来源:WebActivity.java


示例5: doInBackground

import com.google.api.client.auth.oauth.OAuthGetAccessToken; //导入依赖的package包/类
@Override
protected Void doInBackground(Uri... params) {

    Log.i(TAG, "doInbackground called with url " + url);
    if (url.startsWith(Constants.OAUTH_CALLBACK_URL) && !handled) {
        try {

            if (url.indexOf("oauth_token=") != -1) {
                handled = true;
                String requestToken = extractParamFromUrl(url, "oauth_token");
                String verifier = extractParamFromUrl(url, "oauth_verifier");

                OAuthGetAccessToken accessToken = getOAuthAccessToken(requestToken);
                accessToken.verifier = verifier;

                OAuthCredentialsResponse credentials = accessToken.execute();
                signer.tokenSharedSecret = credentials.tokenSecret;
                localCredentialStore.store(new AuthToken(credentials.token, credentials.tokenSecret));

            } else if (url.indexOf("error=") != -1) {
                localCredentialStore.clear();
            }

        } catch (IOException e) {
            Log.e(TAG, e.getMessage(), e);
        }

    }
    return null;
}
 
开发者ID:ipragmatech,项目名称:Android-Magento-Rest-Api-Integration,代码行数:31,代码来源:WebActivity.java


示例6: getOAuthToken

import com.google.api.client.auth.oauth.OAuthGetAccessToken; //导入依赖的package包/类
public String[] getOAuthToken(String tempToken) throws Exception {
	if (tempToken != null) {
		// Step 3: Once the consumer has redirected the user back to the oauth_callback
		// URL you can request the access token the user has approved. You use the
		// request token to sign this request. After this is done you throw away the
		// request token and use the access token returned. You should store this
		// access token somewhere safe, like a database, for future use.
		OAuthGetAccessToken accessToken = new OAuthGetAccessToken(ACCESS_TOKEN_URL);
		accessToken.consumerKey = CONSUMER_KEY;
		accessToken.signer = signer;
		accessToken.transport = http_transport;
		accessToken.temporaryToken = tempToken;

		OAuthCredentialsResponse accessTokenResponse = accessToken.execute();
		Log.d("Philip", "Access Token:");
		Log.d("Philip", "    - oauth_token        = " + accessTokenResponse.token);
		Log.d("Philip", "    - oauth_token_secret = " + accessTokenResponse.tokenSecret);

		// updates signer's token shared secret
		signer.tokenSharedSecret = accessTokenResponse.tokenSecret;
		String[] ar = { accessTokenResponse.token, accessTokenResponse.tokenSecret };

		return ar;
	}
	else {
		throw new Exception(cont.getString(R.string.error_no_temp_token));
	}
}
 
开发者ID:phwoelfel,项目名称:FireHydrantLocator,代码行数:29,代码来源:OAuthTokenmanager.java



注:本文中的com.google.api.client.auth.oauth.OAuthGetAccessToken类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FlyoutPaletteComposite类代码示例发布时间:2022-05-23
下一篇:
Java LocalizationMessages类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap