简体   繁体   中英

Google Library Photos Api

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

so my question is how to pass credentials on this parameter? (i want to use it on native android not web app or backend server ) im really struggling, got google sign in working though if i can use that to get credentials would be great :)

any help is appreciated!

Create a UserCredetials Object

UserCredentials.newBuilder()
    .setClientId("your client id")
    .setClientSecret("your client secret")
    .setAccessToken("Access Token")
    .build()

and pass it to FixedCredentialsProvider.create())

Take a look at this project to get full code https://github.com/erickogi/AndroidGooglePhotosApi/blob/master/app/src/main/java/ke/co/calista/googlephotos/Utils/PhotosLibraryClientFactory.kt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM