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?
json file is generally placed in the app/ directory (at the root of the Android Studio app module).
The most common place is in your project_folder/app folder.
A client_secrets.json file is a JSON formatted file containing the client ID, client secret, and other OAuth 2.0 parameters.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With