Use default credentials for Google app without json file

I created a console application using C #. I used google cloud speech api. I followed this example application to create an application. To authenticate api speech, I wrote the following code in the main method

Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", "path-to-json-file", EnvironmentVariableTarget.Process);

Everything works perfectly. My problem, I have to send exe along with the json file. I do not want to open the json file. How can I embed the contents of a json file in code or authenticate without a json file? so that I can send exe only to the user.

Any help on this would be appreciated.

Thank.

+4
source share
2 answers

, ( ) .

() () , .

0

API :

 Google.Apis.Auth.OAuth2.GoogleCredential cred = Google.Apis.Auth.OAuth2.GoogleCredential.FromJson(JSONString);
 var storage = Google.Cloud.Storage.V1.StorageClient.Create(cred);

, API

0

Source: https://habr.com/ru/post/1670523/


All Articles