Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where must the client_secrets.json file go in Android Studio project folder tree?

There are several sample codes for how to programmatically obtain oauth2 authorization. I copied the code and named my class UtubeUploadAll. My code follows:

  private Credential authorize(List<String> scopes) throws Exception {

  // Load client secrets.
  InputStream cs = UtubeUpload.class.getResourceAsStream(
        "/client_secret.json");

  GoogleClientSecrets clientSecrets = new GoogleClientSecrets();

The statement:

  InputStream cs = UtubeUpload.class.getResourceAsStream(
        "/client_secret.json");

always returns null, no matter where I put the client_secrets.json file. I've put it in directory src, src/main, src/main/java, src/main/res... every place I can think of. I must completely mis-understand something here but I know not what. Can somebody help me out?

like image 945
BinCodinLong Avatar asked Aug 15 '15 18:08

BinCodinLong


People also ask

Where are json files stored in Android project?

json file is generally placed in the app/ directory (at the root of the Android Studio app module).

Where do I put json credentials?

The most common place is in your project_folder/app folder.

What is Client_secrets json?

A client_secrets.json file is a JSON formatted file containing the client ID, client secret, and other OAuth 2.0 parameters.

How do you store client ID and secret?

Use Managed Identity to retrieve the client id + secret and cache them in memory. Use Service Principal credentials (secret or certificate) to retrieve the client id + secret and cache them in memory. Integrate with Key Vault during the release process and store the client id + secret in your local config store.


1 Answers

I was working with the Google Calendar API for Java and had the same problem. Then i found the Google Quickstart Guide which said, that the correct location was src/main/resources/client_secret.json, which worked for me.

like image 172
X.X_Mass_Developer Avatar answered Oct 21 '22 03:10

X.X_Mass_Developer