本文整理汇总了Java中com.google.api.client.auth.oauth2.AuthorizationCodeTokenRequest.execute方法的典型用法代码示例。如果您正苦于以下问题:Java AuthorizationCodeTokenRequest.execute方法的具体用法?Java AuthorizationCodeTokenRequest.execute怎么用?Java AuthorizationCodeTokenRequest.execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.api.client.auth.oauth2.AuthorizationCodeTokenRequest
的用法示例。
在下文中一共展示了AuthorizationCodeTokenRequest.execute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getService
import com.google.api.client.auth.oauth2.AuthorizationCodeTokenRequest; //导入方法依赖的package包/类
/**
* Returns an authorized Bitbucket API service.
* @param authorizationCode authorization code received by the redirection
* endpoint
* @return authorized Bitbucket API service
* @throws IOException if an I/O exception has occurred
* @throws NullPointerException if this object has no client credentials
* @since 5.0
*/
public Service getService(String authorizationCode)
throws IOException {
AuthorizationCodeFlow flow = getAuthorizationCodeFlow(true);
AuthorizationCodeTokenRequest request
= flow.newTokenRequest(authorizationCode);
if (redirectionEndpointUri != null) {
request.setRedirectUri(redirectionEndpointUri);
}
TokenResponse tokenResponse = request.execute();
String tokenType = tokenResponse.getTokenType();
if (!tokenType.equals(BEARER_TOKEN_TYPE)) {
throw new UnknownServiceException("Unsupported token type");
}
return new RestService(
flow.createAndStoreCredential(tokenResponse, getUser()));
}
示例2: getTokenRes
import com.google.api.client.auth.oauth2.AuthorizationCodeTokenRequest; //导入方法依赖的package包/类
/**
* Makes a remote call to the Google Auth server to authorize the grant code,
* in order to issue a request token.
* @param flow
* @param code
* @param callbackUri
* @return
* @throws IOException
*/
private GoogleTokenResponse getTokenRes( AuthorizationCodeFlow flow, String code, String callbackUri )
throws IOException
{
AuthorizationCodeTokenRequest tokenReq = flow
.newTokenRequest( code )
.setRedirectUri( callbackUri );
TokenResponse tokenRes = tokenReq.execute();
return (GoogleTokenResponse)tokenRes;
}