栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

授权给Google客户

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

授权给Google客户

在大多数情况下,无论您在哪里使用

Credential
,都可以使用
StoredCredential
。您只需要使用一点
Credential
,那就是在
OAuth
回调过程中检索访问令牌。从那里
Credential
可以将转换为
StoreCredential
并存储到中
DataStore
。之后,所有存储和检索均与配合使用
StoredCredential


但是有些地方是

StoredCredential
无法使用的。我刚遇到一个尝试创建Google Drive API Service包装器的应用程序。

有一种解决该

GoogleCredential
对象的方法,可以
StoredCredential
根据以下答案创建该对象:
来自GoogleAPI的存储凭据可以使用Java进行重用

import com.google.api.client.auth.oauth2.StoredCredential;public static GoogleCredential createGoogleCredential(StoredCredential storedCredential) {    GoogleCredential googleCredential = new GoogleCredential.Builder()        .setTransport(new NetHttpTransport())        .setJsonFactory(new JacksonFactory())        .setClientSecrets("client_id", "client_secret")        .setAccessToken(storedCredential.getAccessToken())        .build();    return googleCredential;}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/463564.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号