本文整理汇总了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;
}