Arun Kumar
Arun Kumar

Reputation: 13

How to access the google credentials json file by placing in app folder of project and how to pass that path to the GoogleCredentials

Here am accessing the credentials file by placing file in raw folder I am passing the path like this

GoogleCredentials.fromStream(new FileInputStream("android.resource://com.tvs.digi.dmsapp/raw/dms_app_google"))

And I am getting below error

android.resource:/com.tvs.digi.dmsapp/raw/dms_app_google: open failed: ENOENT (No such file or directory)

Upvotes: 1

Views: 1852

Answers (1)

Patibandha Parth
Patibandha Parth

Reputation: 155

Kindly use below code for access your json file.

Update: 2 Can you please try to set the environment variable by adding json file path.

 Set enviroment varibale

val inputStream = this.getAssets().open("XXXXX-6e000f81XXXX.json")
val credentials = GoogleCredentials.fromStream(inputStream)        .createScoped(Lists.newArrayList("https://www.googleapis.com/auth/cloudplatform"))
val credentialsProvider = FixedCredentialsProvider.create(credentials)
val speechSettings = SpeechSettings.newBuilder().setCredentialsProvider(credentialsProvider).build();

Hope it helps you.

Upvotes: 2

Related Questions