本文整理匯總了Java中com.google.api.client.auth.oauth2.Credential.refreshToken方法的典型用法代碼示例。如果您正苦於以下問題:Java Credential.refreshToken方法的具體用法?Java Credential.refreshToken怎麽用?Java Credential.refreshToken使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.api.client.auth.oauth2.Credential
的用法示例。
在下文中一共展示了Credential.refreshToken方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: authorize
import com.google.api.client.auth.oauth2.Credential; //導入方法依賴的package包/類
public static Credential authorize(String clientId, String clientSecret, Class<?> preferencesNode) throws Exception {
String authInfoJSon = "{\"installed\":{\"client_id\":\"%s\",\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\",\"client_secret\":\"%s\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"http://localhost\"]}}";
Reader authStream = new StringReader(String.format(authInfoJSon, clientId, clientSecret));
Credential result = authorize(authStream, preferencesNode);
result.refreshToken();
return result;
}
示例2: authorize
import com.google.api.client.auth.oauth2.Credential; //導入方法依賴的package包/類
public static Credential authorize(Optional<AuthInfo> authInfo, Class<?> dataStoreCarrierNode) throws Exception {
String authInfoJSon = "{\"installed\":{\"client_id\":\"%s\",\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\",\"client_secret\":\"%s\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"http://localhost\"]}}";
Reader authStream;
authStream = new StringReader(
String.format(authInfoJSon, authInfo.get().clientId, authInfo.get().clientSecret));
Credential result = Auth.authorize(authStream, dataStoreCarrierNode);
result.refreshToken();
return result;
}