当前位置: 首页>>代码示例>>Java>>正文


Java Credential.setRefreshToken方法代码示例

本文整理汇总了Java中com.google.api.client.auth.oauth2.Credential.setRefreshToken方法的典型用法代码示例。如果您正苦于以下问题:Java Credential.setRefreshToken方法的具体用法?Java Credential.setRefreshToken怎么用?Java Credential.setRefreshToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.api.client.auth.oauth2.Credential的用法示例。


在下文中一共展示了Credential.setRefreshToken方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: makeClient

import com.google.api.client.auth.oauth2.Credential; //导入方法依赖的package包/类
@Override
public Calendar makeClient(String clientId, String clientSecret,
                           Collection<String> scopes, String applicationName, String refreshToken,
                           String accessToken, String emailAddress, String p12FileName, String user) {

    Credential credential;
    try {
        // if emailAddress and p12FileName values are present, assume Google Service Account
        if (null != emailAddress && !"".equals(emailAddress) && null != p12FileName && !"".equals(p12FileName)) {
            credential = authorizeServiceAccount(emailAddress, p12FileName, scopes, user);
        } else {
            credential = authorize(clientId, clientSecret, scopes);
            if (refreshToken != null && !"".equals(refreshToken)) {
                credential.setRefreshToken(refreshToken);
            }
            if (accessToken != null && !"".equals(accessToken)) {
                credential.setAccessToken(accessToken);
            }
        }
        return new Calendar.Builder(transport, jsonFactory, credential).setApplicationName(applicationName).build();
    } catch (Exception e) {
        LOG.error("Could not create Google Drive client.", e);
    }
    return null;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:26,代码来源:BatchGoogleCalendarClientFactory.java

示例2: makeClient

import com.google.api.client.auth.oauth2.Credential; //导入方法依赖的package包/类
@Override
public Drive makeClient(String clientId, String clientSecret, Collection<String> scopes, String applicationName, String refreshToken, String accessToken) {
    Credential credential;
    try {
        credential = authorize(clientId, clientSecret, scopes);

        if (refreshToken != null && !"".equals(refreshToken)) {
            credential.setRefreshToken(refreshToken);
        } 
        if (accessToken != null && !"".equals(accessToken)) {
            credential.setAccessToken(accessToken);
        }
        return new Drive.Builder(transport, jsonFactory, credential).setApplicationName(applicationName).build();
    } catch (Exception e) {
        LOG.error("Could not create Google Drive client.", e);            
    }
    return null;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:BatchGoogleDriveClientFactory.java

示例3: makeClient

import com.google.api.client.auth.oauth2.Credential; //导入方法依赖的package包/类
@Override
public Gmail makeClient(String clientId, String clientSecret, Collection<String> scopes, String applicationName, String refreshToken, String accessToken) {
    Credential credential;
    try {
        credential = authorize(clientId, clientSecret, scopes);

        if (refreshToken != null && !"".equals(refreshToken)) {
            credential.setRefreshToken(refreshToken);
        }
        if (accessToken != null && !"".equals(accessToken)) {
            credential.setAccessToken(accessToken);
        }
        return new Gmail.Builder(transport, jsonFactory, credential).setApplicationName(applicationName).build();
    } catch (Exception e) {
        LOG.error("Could not create Google Drive client.", e);
    }
    return null;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:BatchGoogleMailClientFactory.java

示例4: load

import com.google.api.client.auth.oauth2.Credential; //导入方法依赖的package包/类
@Override
public boolean load(String userId, Credential credential) throws IOException {
    Log.i(BnConstants.TAG, "Loading credential for userId ".concat(userId));
    Log.i(BnConstants.TAG, "Loaded access token = ".concat(prefs.getString(userId + ACCESS_TOKEN, "")));

    credential.setAccessToken(prefs.getString(userId + ACCESS_TOKEN, null));

    if (prefs.contains(userId + EXPIRES_IN)) {
        credential.setExpirationTimeMilliseconds(prefs.getLong(userId + EXPIRES_IN,0));
    }
    credential.setRefreshToken(prefs.getString(userId + REFRESH_TOKEN, null));

    return true;
}
 
开发者ID:dementhius,项目名称:battlenet-oauth2,代码行数:15,代码来源:BnSharedPreferencesCredentialStore.java


注:本文中的com.google.api.client.auth.oauth2.Credential.setRefreshToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。