本文整理汇总了Java中com.google.api.client.auth.oauth.OAuthCredentialsResponse类的典型用法代码示例。如果您正苦于以下问题:Java OAuthCredentialsResponse类的具体用法?Java OAuthCredentialsResponse怎么用?Java OAuthCredentialsResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OAuthCredentialsResponse类属于com.google.api.client.auth.oauth包,在下文中一共展示了OAuthCredentialsResponse类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: new10aTokenRequest
import com.google.api.client.auth.oauth.OAuthCredentialsResponse; //导入依赖的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: getTempToken
import com.google.api.client.auth.oauth.OAuthCredentialsResponse; //导入依赖的package包/类
public String getTempToken() throws IOException {
// Step 1: Get a request token. This is a temporary token that is used for
// having the user authorize an access token and to sign the request to obtain
// said access token.
OAuthGetTemporaryToken requestTempToken = new OAuthGetTemporaryToken(REQUEST_TOKEN_URL);
requestTempToken.consumerKey = CONSUMER_KEY;
requestTempToken.transport = http_transport;
requestTempToken.signer = signer;
OAuthCredentialsResponse requestTokenResponse = requestTempToken.execute();
Log.d("Philip", "Request Temp Token:");
Log.d("Philip", " - oauth_token = " + requestTokenResponse.token);
Log.d("Philip", " - oauth_token_secret = " + requestTokenResponse.tokenSecret);
// updates signer's token shared secret
signer.tokenSharedSecret = requestTokenResponse.tokenSecret;
return requestTokenResponse.token;
}
开发者ID:phwoelfel,项目名称:FireHydrantLocator,代码行数:21,代码来源:OAuthTokenmanager.java
示例3: execute
import com.google.api.client.auth.oauth.OAuthCredentialsResponse; //导入依赖的package包/类
public void execute() {
OAuthSigner signer = signerFactory.createSigner(null);
tokenRequest = new OAuthGetTemporaryToken(config.getRequestTokenUrl());
tokenRequest.consumerKey = config.getConsumerKey();
tokenRequest.callback = config.getRedirectUri();
ApacheHttpTransport.Builder transBuilder = new ApacheHttpTransport.Builder();
if (config.getProxyHost() != null && "" != config.getProxyHost()) {
String proxy_host = config.getProxyHost();
long proxy_port = config.getProxyPort();
boolean proxyHttps = config.getProxyHttpsEnabled();
String proxy_schema = proxyHttps == true ? "https" : "http";
System.out.println("proxy.host=" + proxy_host + ", proxy.port=" + proxy_port + ", proxy_schema=" + proxy_schema);
HttpHost proxy = new HttpHost(proxy_host, (int) proxy_port, proxy_schema);
transBuilder.setProxy(proxy);
tokenRequest.transport = transBuilder.build();
} else {
tokenRequest.transport = new ApacheHttpTransport();
}
tokenRequest.signer = signer;
OAuthCredentialsResponse temporaryTokenResponse = null;
try {
temporaryTokenResponse = tokenRequest.execute();
tempToken = temporaryTokenResponse.token;
tempTokenSecret = temporaryTokenResponse.tokenSecret;
} catch (IOException e) {
e.printStackTrace();
}
}
开发者ID:XeroAPI,项目名称:Xero-Java,代码行数:34,代码来源:OAuthRequestToken.java
示例4: doInBackground
import com.google.api.client.auth.oauth.OAuthCredentialsResponse; //导入依赖的package包/类
@Override
protected Void doInBackground(Uri... params) {
try {
signer.clientSharedSecret = Constants.CONSUMER_SECRET;
OAuthGetTemporaryToken temporaryToken = new OAuthGetTemporaryToken(Constants.REQUEST_URL);
temporaryToken.transport = new ApacheHttpTransport();
temporaryToken.signer = signer;
temporaryToken.consumerKey = Constants.CONSUMER_KEY;
temporaryToken.callback = Constants.OAUTH_CALLBACK_URL;
OAuthCredentialsResponse tempCredentials = temporaryToken.execute();
signer.tokenSharedSecret = tempCredentials.tokenSecret;
OAuthAuthorizeTemporaryTokenUrl authorizeUrl = new OAuthAuthorizeTemporaryTokenUrl(Constants.AUTHORIZE_URL);
authorizeUrl.temporaryToken = tempCredentials.token;
authorizationUrl = authorizeUrl.build();
handled = false;
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
开发者ID:ipragmatech,项目名称:OAuth-Magento-Rest-Api-Retrofit,代码行数:28,代码来源:WebActivity.java
示例5: computeAuthorizationHeader
import com.google.api.client.auth.oauth.OAuthCredentialsResponse; //导入依赖的package包/类
/**
* Compute the Authorization header to sign the OAuth 1 request.
*
* @param userId the user id.
* @param requestMethod the HTTP request method.
* @param requestUrl the HTTP request url with encoded query parameters.
* @return the authorization header value, or {@code null} if token was not found for given user
* id.
* @throws OAuthAuthenticationException if authentication failed.
*/
String computeAuthorizationHeader(
final String userId, final String requestMethod, final String requestUrl)
throws OAuthAuthenticationException {
final OAuthCredentialsResponse credentials = new OAuthCredentialsResponse();
OAuthToken oauthToken = getToken(userId);
credentials.token = oauthToken != null ? oauthToken.getToken() : null;
if (credentials.token != null) {
return computeAuthorizationHeader(
requestMethod, requestUrl, credentials.token, credentials.tokenSecret);
}
return null;
}
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:OAuthAuthenticator.java
示例6: getToken
import com.google.api.client.auth.oauth.OAuthCredentialsResponse; //导入依赖的package包/类
private OAuthToken getToken(final String userId) {
OAuthCredentialsResponse credentials;
credentialsStoreLock.lock();
try {
credentials = credentialsStore.get(userId);
} finally {
credentialsStoreLock.unlock();
}
if (credentials != null) {
return newDto(OAuthToken.class)
.withToken(credentials.token)
.withScope(credentials.tokenSecret);
}
return null;
}
开发者ID:eclipse,项目名称:che,代码行数:16,代码来源:OAuthAuthenticator.java
示例7: new10aTemporaryTokenRequest
import com.google.api.client.auth.oauth.OAuthCredentialsResponse; //导入依赖的package包/类
/**
* Returns the response of a Request Token request as defined in <a
* href="http://oauth.net/core/1.0a/#auth_step1">Obtaining an Unauthorized
* Request Token</a>.
*
* @param redirectUri the {@code oauth_callback} as defined in <a
* href="http://oauth.net/core/1.0a/#rfc.section.6.1.1">Consumer
* Obtains a Request Token</a>
* @return
* @throws IOException
*/
public OAuthCredentialsResponse new10aTemporaryTokenRequest(String redirectUri)
throws IOException {
OAuthGetTemporaryToken temporaryToken =
new OAuthGetTemporaryToken(getTemporaryTokenRequestUrl());
OAuthHmacSigner signer = new OAuthHmacSigner();
ClientParametersAuthentication clientAuthentication = (ClientParametersAuthentication) getClientAuthentication();
signer.clientSharedSecret = clientAuthentication.getClientSecret();
temporaryToken.signer = signer;
temporaryToken.consumerKey = clientAuthentication.getClientId();
temporaryToken.callback = redirectUri;
temporaryToken.transport = getTransport();
return temporaryToken.execute();
}
开发者ID:agilie,项目名称:dribbble-android-sdk,代码行数:25,代码来源:AuthorizationFlow.java
示例8: createAndStoreCredential
import com.google.api.client.auth.oauth.OAuthCredentialsResponse; //导入依赖的package包/类
/**
* Creates a new credential for the given user ID based on the given token
* response and store in the credential store.
*
* @param response OAuth 1.0a authorization token response
* @param userId user ID or {@code null} if not using a persisted credential
* store
* @return newly created credential
* @throws IOException
*/
public OAuthHmacCredential createAndStoreCredential(OAuthCredentialsResponse response,
String userId) throws IOException {
OAuthHmacCredential credential = new10aCredential(userId)
.setAccessToken(response.token)
.setTokenSharedSecret(response.tokenSecret);
CredentialStore credentialStore = getCredentialStore();
if (credentialStore != null) {
credentialStore.store(userId, credential);
}
if (credentialCreatedListener != null) {
credentialCreatedListener.onCredentialCreated(credential, response);
}
return credential;
}
开发者ID:agilie,项目名称:dribbble-android-sdk,代码行数:25,代码来源:AuthorizationFlow.java
示例9: getOAuthToken
import com.google.api.client.auth.oauth.OAuthCredentialsResponse; //导入依赖的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
示例10: authorize10a
import com.google.api.client.auth.oauth.OAuthCredentialsResponse; //导入依赖的package包/类
/**
* Authorizes the Android application to access user's protected data using
* the authorization flow in OAuth 1.0a.
*
* @param userId user ID or {@code null} if not using a persisted credential
* store
* @param callback Callback to invoke when the request completes,
* {@code null} for no callback
* @param handler {@link Handler} identifying the callback thread,
* {@code null} for the main thread
* @return An {@link OAuthFuture} which resolves to a {@link Credential}
*/
public OAuthFuture<Credential> authorize10a(final String userId,
final OAuthCallback<Credential> callback, Handler handler) {
Preconditions.checkNotNull(userId);
final Future2Task<Credential> task = new Future2Task<Credential>(handler, callback) {
@Override
public void doWork() throws Exception {
try {
LOGGER.info("authorize10a");
OAuthHmacCredential credential = mFlow.load10aCredential(userId);
if (credential != null && credential.getAccessToken() != null
&& (credential.getRefreshToken() != null
|| credential.getExpiresInSeconds() == null
|| credential.getExpiresInSeconds() > 60)) {
set(credential);
return;
}
String redirectUri = mUIController.getRedirectUri();
OAuthCredentialsResponse tempCredentials =
mFlow.new10aTemporaryTokenRequest(redirectUri);
OAuthAuthorizeTemporaryTokenUrl authorizationUrl =
mFlow.new10aAuthorizationUrl(tempCredentials.token);
mUIController.requestAuthorization(authorizationUrl);
String code = mUIController.waitForVerifierCode();
OAuthCredentialsResponse response =
mFlow.new10aTokenRequest(tempCredentials, code).execute();
credential = mFlow.createAndStoreCredential(response, userId);
set(credential);
} finally {
mUIController.stop();
}
}
};
// run the task in a background thread
submitTaskToExecutor(task);
return task;
}
开发者ID:agilie,项目名称:dribbble-android-sdk,代码行数:57,代码来源:OAuthManager.java
示例11: onCredentialCreated
import com.google.api.client.auth.oauth.OAuthCredentialsResponse; //导入依赖的package包/类
/**
* Notifies of a created credential after a successful token response in
* {@link AuthorizationFlow#createAndStoreCredential(OAuthCredentialsResponse, String)}
*
* @param credential
* @param oauth10aResponse
* @throws IOException
*/
void onCredentialCreated(Credential credential, OAuthCredentialsResponse oauth10aResponse)
throws IOException;
开发者ID:agilie,项目名称:dribbble-android-sdk,代码行数:11,代码来源:AuthorizationFlow.java
注:本文中的com.google.api.client.auth.oauth.OAuthCredentialsResponse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论