Java Code Examples for org.scribe.model.Token#getRawResponse()
The following examples show how to use
org.scribe.model.Token#getRawResponse() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HubicOAuth20ServiceImpl.java From swift-explorer with Apache License 2.0 | 6 votes |
public Token refreshAccessToken (Token expiredToken) { if (expiredToken == null) return null ; OAuthRequest request = new OAuthRequest(api.getAccessTokenVerb(), api.getAccessTokenEndpoint()); String authenticationCode = config.getApiKey() + ":" + config.getApiSecret() ; byte[] bytesEncodedAuthenticationCode = Base64.encodeBase64(authenticationCode.getBytes()); request.addHeader ("Authorization", "Basic " + bytesEncodedAuthenticationCode) ; String charset = "UTF-8"; request.setCharset(charset); request.setFollowRedirects(false); AccessToken at = new HubicTokenExtractorImpl ().getAccessToken(expiredToken.getRawResponse()) ; try { request.addBodyParameter("refresh_token", at.getRefreshToken()); //request.addBodyParameter("refresh_token", URLEncoder.encode(at.getRefreshToken(), charset)); request.addBodyParameter("grant_type", "refresh_token"); request.addBodyParameter(OAuthConstants.CLIENT_ID, URLEncoder.encode(config.getApiKey(), charset)); request.addBodyParameter(OAuthConstants.CLIENT_SECRET, URLEncoder.encode(config.getApiSecret(), charset)); } catch (UnsupportedEncodingException e) { logger.error("Error occurred while refreshing the access token", e); } Response response = request.send(); Token newToken = api.getAccessTokenExtractor().extract(response.getBody()); // We need to keep the initial RowResponse because it contains the refresh token return new Token (newToken.getToken(), newToken.getSecret(), expiredToken.getRawResponse()) ; }
Example 2
Source File: WeiXinOAuth20ServiceImpl.java From cas4.0.x-server-wechat with Apache License 2.0 | 5 votes |
@Override public void signRequest(final Token accessToken, final OAuthRequest request) { request.addQuerystringParameter(OAuthConstants.ACCESS_TOKEN, accessToken.getToken()); String response = accessToken.getRawResponse(); Matcher matcher = openIdPattern.matcher(response); if (matcher.find()) { request.addQuerystringParameter("openid", matcher.group(1)); } else { throw new OAuthException("微信接口返回数据miss openid: " + response); } }
Example 3
Source File: EvernoteAuthToken.java From EverMemo with MIT License | 5 votes |
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)); }
Example 4
Source File: EvernoteAuthToken.java From EverMemo-EverNote with MIT License | 5 votes |
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)); }