gpt4 book ai didi

java - Google 图书馆照片 API

转载 作者:太空狗 更新时间:2023-10-29 14:37:43 25 4
gpt4 key购买 nike

 // 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
}

所以我的问题是如何传递此参数的凭据? (我想在 native android 上使用它,而不是网络应用程序或后端服务器)我真的很挣扎,让谷歌登录工作,但如果我可以使用它来获取凭据会很棒:)

感谢任何帮助!

最佳答案

创建一个 UserCredetials 对象

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

关于java - Google 图书馆照片 API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53319582/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com