Search code examples
androidoauth-2.0google-apicredentialsgoogle-photos-api

How to access Google Photos Library API without CLIENT_SECRET in android


I'm building an android application(no backend server) using Photos Library API , it access to google photos and manage image .

There are three step:

  1. Google Sign in
  2. Authentication app use Google Photos
  3. Access Google Photos

Im stucking with step 3

First , I create an client :

            settings = PhotosLibrarySettings.newBuilder()
                    .setCredentialsProvider(
                            FixedCredentialsProvider.create(getUserCredentials(token)))
                    .build()
            return PhotosLibraryClient.initialize(settings)

in getUserCredential method, it return a Credential:

    fun getUserCredentials(token: String): Credentials? {
        val a = AccessToken(token, null)

        return UserCredentials.newBuilder()
                .setClientId("client_id.apps.googleusercontent.com")
                .setClientSecret("")
                .setAccessToken(a)
                .build()
    }

But problem is I can't find Client Secret in Google Console, it just have Client ID. I'm tried with Json file downloaded from Console, but it doesn't have client_secret field, and it return null on this field

Question is : How to get Client Secret for Android Application, or another way to get Credential without client secret

Can I have a solution for this problem ????


Solution

  • I had a same issue. You don't have to use exactly client secret from Android Application. You could use client secret from Web App, and your android app still work fine