首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Google Library Photos Api

Google Library Photos Api
EN

Stack Overflow用户
提问于 2018-11-15 20:31:26
回答 1查看 485关注 0票数 3
代码语言:javascript
复制
 // Set up the Photos Library Client that interacts with the API
  PhotosLibrarySettings settings =
     PhotosLibrarySettings.newBuilder()
     .setCredentialsProvider(
         FixedCredentialsProvider.create(/* Add credentials here. 
 */)) 
    .build();

 try (PhotosLibraryClient photosLibraryClient =
    PhotosLibraryClient.initialize(settings)) {

    // Create a new Album  with at title
    Album createdAlbum = photosLibraryClient.createAlbum("My 
Album");

// Get some properties from the album, such as its ID and 
product URL
    String id = album.getId();
    String url = album.getProductUrl();

}    catch (ApiException e) {
    // Error during album creation
}

所以我的问题是如何在这个参数上传递凭证?(我想在原生android上使用它,而不是web应用程序或后端服务器)我真的很努力,让谷歌登录工作,但如果我可以用它来获得凭据将是很棒的:)

如有任何帮助,我们不胜感激!

EN

回答 1

Stack Overflow用户

发布于 2019-02-05 21:01:54

创建UserCredetials对象

代码语言:javascript
复制
UserCredentials.newBuilder()
    .setClientId("your client id")
    .setClientSecret("your client secret")
    .setAccessToken("Access Token")
    .build()

并将其传递给FixedCredentialsProvider.create())

请查看此项目以获取完整的代码https://github.com/erickogi/AndroidGooglePhotosApi/blob/master/app/src/main/java/ke/co/calista/googlephotos/Utils/PhotosLibraryClientFactory.kt

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53319582

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档