當前位置: 首頁>>代碼示例>>Java>>正文


Java Token.getToken方法代碼示例

本文整理匯總了Java中org.scribe.model.Token.getToken方法的典型用法代碼示例。如果您正苦於以下問題:Java Token.getToken方法的具體用法?Java Token.getToken怎麽用?Java Token.getToken使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.scribe.model.Token的用法示例。


在下文中一共展示了Token.getToken方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAccessToken

import org.scribe.model.Token; //導入方法依賴的package包/類
@Override
public Token getAccessToken(Token token, Verifier verifier) {
  OAuthRequest request =
      new OAuthRequest(api.getAccessTokenVerb(), api.getAccessTokenEndpoint());
  request.addHeader("Authorization", prepareAuthorizationHeaderValue());
  request.addBodyParameter(GRANT_TYPE, GRANT_TYPE_VALUE);
  request.addBodyParameter(CODE, verifier.getValue());
  Response response = request.send();
  if (response.getCode() == SC_OK) {
    Token t = api.getAccessTokenExtractor().extract(response.getBody());
    return new Token(t.getToken(), config.getApiSecret());
  }

  throw new OAuthException(
      String.format(
          "Error response received: %s, HTTP status: %s",
          response.getBody(), response.getCode()));
}
 
開發者ID:davido,項目名稱:gerrit-oauth-provider,代碼行數:19,代碼來源:BitbucketApi.java

示例2: getAccessToken

import org.scribe.model.Token; //導入方法依賴的package包/類
@Override
public OAuthToken getAccessToken(OAuthVerifier rv) {
  Verifier vi = new Verifier(rv.getValue());
  Token to = service.getAccessToken(null, vi);
  OAuthToken result = new OAuthToken(to.getToken(), to.getSecret(), to.getRawResponse());
  return result;
}
 
開發者ID:davido,項目名稱:gerrit-oauth-provider,代碼行數:8,代碼來源:GoogleOAuthService.java

示例3: getAccessToken

import org.scribe.model.Token; //導入方法依賴的package包/類
@Override
public OAuthToken getAccessToken(OAuthVerifier rv) {
  Verifier vi = new Verifier(rv.getValue());
  Token to = service.getAccessToken(null, vi);
  OAuthToken result = new OAuthToken(to.getToken(), to.getSecret(), to.getRawResponse());

  return result;
}
 
開發者ID:davido,項目名稱:gerrit-oauth-provider,代碼行數:9,代碼來源:FacebookOAuthService.java

示例4: finishAuthorization

import org.scribe.model.Token; //導入方法依賴的package包/類
public boolean finishAuthorization(Activity activity, int resultCode, Intent data) {
    if (resultCode != Activity.RESULT_OK || data == null) {
        return false;
    }

    String url = data.getStringExtra(EvernoteUtil.EXTRA_OAUTH_CALLBACK_URL);
    if (TextUtils.isEmpty(url)) {
        return false;
    }

    Uri uri = Uri.parse(url);

    String verifierString = uri.getQueryParameter("oauth_verifier");
    String appLnbString = uri.getQueryParameter("sandbox_lnb");
    boolean isAppLinkedNotebook = !TextUtils.isEmpty(appLnbString) && "true".equalsIgnoreCase(appLnbString);

    if (TextUtils.isEmpty(verifierString)) {
        CAT.i("User did not authorize access");
        return false;
    }

    Verifier verifier = new Verifier(verifierString);
    try {
        Token accessToken = mOAuthService.getAccessToken(mRequestToken, verifier);
        String rawResponse = accessToken.getRawResponse();

        String authToken = accessToken.getToken();
        String noteStoreUrl = extract(rawResponse, NOTE_STORE_REGEX);
        String webApiUrlPrefix = extract(rawResponse, WEB_API_REGEX);
        int userId = Integer.parseInt(extract(rawResponse, USER_ID_REGEX));

        String evernoteHost = mBootstrapProfile.getSettings().getServiceHost();

        AuthenticationResult authenticationResult = new AuthenticationResult(authToken, noteStoreUrl, webApiUrlPrefix, evernoteHost, userId, isAppLinkedNotebook);
        authenticationResult.persist();
        mSession.setAuthenticationResult(authenticationResult);
        return true;

    } catch (Exception e) {
        CAT.e("Failed to obtain OAuth access token", e);
    }

    return false;
}
 
開發者ID:fivef,項目名稱:add_to_evernote_note,代碼行數:45,代碼來源:EvernoteOAuthHelper.java

示例5: generateAccessTokenString

import org.scribe.model.Token; //導入方法依賴的package包/類
public static String generateAccessTokenString(Token accessTokenObj)
{
	return accessTokenObj.getToken() + "&" + accessTokenObj.getSecret();
}
 
開發者ID:edgehosting,項目名稱:jira-dvcs-connector,代碼行數:5,代碼來源:BitbucketOAuthAuthentication.java

示例6: getAccessToken

import org.scribe.model.Token; //導入方法依賴的package包/類
@Override
public OAuthToken getAccessToken(OAuthVerifier rv) {
  Verifier vi = new Verifier(rv.getValue());
  Token to = service.getAccessToken(null, vi);
  return new OAuthToken(to.getToken(), to.getSecret(), to.getRawResponse());
}
 
開發者ID:davido,項目名稱:gerrit-oauth-provider,代碼行數:7,代碼來源:CasOAuthService.java

示例7: getAccessToken

import org.scribe.model.Token; //導入方法依賴的package包/類
@Override
public OAuthToken getAccessToken(OAuthVerifier rv) {
  Verifier vi = new Verifier(rv.getValue());
  Token to = service.getAccessToken(null, vi);
  return new OAuthToken(to.getToken(), to.getSecret(), null);
}
 
開發者ID:davido,項目名稱:gerrit-oauth-provider,代碼行數:7,代碼來源:BitbucketOAuthService.java

示例8: EvernoteAuthToken

import org.scribe.model.Token; //導入方法依賴的package包/類
public EvernoteAuthToken(Token token) {
  super(token.getToken(), token.getSecret(), token.getRawResponse());
  this.mNoteStoreUrl = extract(getRawResponse(), NOTESTORE_REGEX);
  this.mWebApiUrlPrefix = extract(getRawResponse(), WEBAPI_REGEX);
  this.mUserId = Integer.parseInt(extract(getRawResponse(), USERID_REGEX));
}
 
開發者ID:duanze,項目名稱:PureNote,代碼行數:7,代碼來源:EvernoteAuthToken.java

示例9: doInBackground

import org.scribe.model.Token; //導入方法依賴的package包/類
@Override
protected String doInBackground(Void... params) {
    String url = null;
    try {

        EvernoteSession session = EvernoteSession.getOpenSession();
        if (session != null) {
            //Network request
            BootstrapManager.BootstrapInfoWrapper infoWrapper = session.getBootstrapSession().getBootstrapInfo();

            if (infoWrapper != null) {
                BootstrapInfo info = infoWrapper.getBootstrapInfo();
                if (info != null) {
                    mBootstrapProfiles = (ArrayList<BootstrapProfile>) info.getProfiles();
                    if (mBootstrapProfiles != null &&
                            mBootstrapProfiles.size() > 0 &&
                            mSelectedBootstrapProfilePos < mBootstrapProfiles.size()) {

                        mSelectedBootstrapProfile = mBootstrapProfiles.get(mSelectedBootstrapProfilePos);
                    }
                }
            }
        }

        if (mSelectedBootstrapProfile == null || TextUtils.isEmpty(mSelectedBootstrapProfile.getSettings().getServiceHost())) {
            Log.d(LOGTAG, "Bootstrap did not return a valid host");
            return null;
        }

        OAuthService service = createService();

        Log.i(LOGTAG, "Retrieving OAuth request token...");
        Token reqToken = service.getRequestToken();
        mRequestToken = reqToken.getToken();
        mRequestTokenSecret = reqToken.getSecret();

        Log.i(LOGTAG, "Redirecting user for authorization...");
        url = service.getAuthorizationUrl(reqToken);
        if (mSupportAppLinkedNotebooks) {
            url += "&supportLinkedSandbox=true";
        }
    } catch (BootstrapManager.ClientUnsupportedException cue) {

        return null;
    } catch (Exception ex) {
        Log.e(LOGTAG, "Failed to obtain OAuth request token", ex);
    }
    return url;
}
 
開發者ID:duanze,項目名稱:PureNote,代碼行數:50,代碼來源:EvernoteOAuthActivity.java


注:本文中的org.scribe.model.Token.getToken方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。