Google Speech-to-Text API Unauthorized error : - java

I am creating a new Speechclient from the Google Cloud Speech library with the system environment variable GOOGLE_APPLICATION_CREDENTIALS set to the path of my Cloud Platform service account JSON file. I am getting the following error:
INFO:
Failed to detect whether we are running on Google Compute Engine.
Exception in thread "main" com.google.cloud.storage.StorageException: Anonymous caller does not have storage.buckets.get access to the Google Cloud Storage bucket.
at com.google.cloud.storage.spi.v1.HttpStorageRpc.translate(HttpStorageRpc.java:229)
at com.google.cloud.storage.spi.v1.HttpStorageRpc.get(HttpStorageRpc.java:406)
at com.google.cloud.storage.StorageImpl$4.call(StorageImpl.java:217)
at com.google.cloud.storage.StorageImpl$4.call(StorageImpl.java:214)
at com.google.api.gax.retrying.DirectRetryingExecutor.submit(DirectRetryingExecutor.java:105)
at com.google.cloud.RetryHelper.run(RetryHelper.java:76)
at com.google.cloud.RetryHelper.runWithRetries(RetryHelper.java:50)
at com.google.cloud.storage.StorageImpl.get(StorageImpl.java:213)
at Main.listOfObjects(Main.java:47)
at Main.getListOfObjects(Main.java:63)
at Main.runListOfAudioFiles(Main.java:68)
at Main.main(Main.java:179)
Caused by: com.google.api.client.googleapis.json.GoogleJsonResponseException: 401 Unauthorized
{
"code" : 401,
"errors" : [ {
"domain" : "global",
"location" : "Authorization",
"locationType" : "header",
"message" : "Anonymous caller does not have storage.buckets.get access to the Google Cloud Storage bucket.",
"reason" : "required"
} ],
"message" : "Anonymous caller does not have storage.buckets.get access to the Google Cloud Storage bucket."
][1]
I have logged in to my GCP project in the command line with gcloud init. That did not have any effect, I am still getting the same above error.
I attempted to authorize the project with explicit credentials as suggested here but I got the following error:
INFO:
Failed to detect whether we are running on Google Compute Engine.
Failed to create the client due to: java.io.IOException: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.
I am running on IntelliJ Idea with the Cloud Code plugin.
I am not sure how to proceed from here, any help would be appreciated, thanks!

Related

Exception while sending response back to Google Business API

We have deployed a java web application to server as a Webhook endpoint to receive messages from Google business messages platform. Request is reaching fine to the endpoint but while sending back the response, we are facing an exception from the google business api. PFB response we are getting,
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
"code" : 403,
"errors" : [ {
"domain" : "global",
"message" : "Your partner account doesn't have access to this conversation.",
"reason" : "forbidden"
} ],
"message" : "Your partner account doesn't have access to this conversation.",
"status" : "PERMISSION_DENIED"
}
We have enabled the google business API and google communications API for our project.
ANd project is also registered as a partner with google business messages.
I need help to resolve this issue. Please let me know if there are any further permissions we need to give to make this work.
We tried using the service account json to send back the response to api, but still giving the same error.

My app can not create file in "appDataFolder" of google drive

How can I create a file in google drive "appDataFolder"?
I created google developer console settings which is necessary for creating file and accessing "appDataFolder".
google developer console
Android Studio output error messages as below.
W/System.err: com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
"code": 403,
"errors": [
{
"domain": "global",
"message": "The granted scopes do not allow use of the Application Data folder.",
"reason": "insufficientScopes"
}
],
"message": "The granted scopes do not allow use of the Application Data folder."
}
W/System.err: at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:432)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
at com.example.test1.MainActivity$3.run(MainActivity.java:131)
at java.lang.Thread.run(Thread.java:923)
Source code is
File body = new File();
body.setName(FILE_TITLE);//fileContent.getName());
body.setMimeType("text/plain");
body.setParents(Collections.singletonList("appDataFolder"));
File file = service.files().create(body, content)
.setFields("id")
.execute();
If the following line is commented out in the source code, my app can create a file in google drive
top folder not "appDataFolder".
body.setParents(Collections.singletonList("appDataFolder"));
Android Studio 4.1.2
enter image description here
Best regards.
Thanks in advance.
While from the looks of your developer console image you apear to have include a large number of scopes. The issue here is not with your settings in google developer console but rather with the scopes you have authorized your user with.
When you run your application the user is asked to consent to your accessing some of their data, this is the scope of authorization for your application. It defines what the user has granted your application access to do.
If your code only requests read only access then and you try to write to it then your going to see an insufficientScopes error message.
You need to check what scope is required of the method you are using and then make sure when you authorize your user that you are requesting that scope.
My guess is you have something like this
private static final List<String> SCOPES = Collections.singletonList(DriveScopes.DRIVE_METADATA_READONLY);
YOu need to include this scope https://www.googleapis.com/auth/drive.appdata which is probably something like DriveScopes.DRIVE_APPDATA
Remember once the scopes have been changed in your application you will need to reauthorize the user. If your storing the consent then it needs to be removed in order to request authorization again.

Firebase authorisation error for otp auth

getting this error message in logcat after entering the mobile number and clicking on verify.
2020-12-12 18:23:55.403 15226-15226/com.example.proj1 E/zzf: Problem retrieving SafetyNet Token: 7:
2020-12-12 17:28:13.461 29510-31007/com.example.proj1 E/FirebaseAuth: [GetAuthDomainTask] Error getting project config. Failed with {
"error": {
"code": 400,
"message": "INVALID_CERT_HASH : Client does not match API key",
"errors": [
{
"message": "INVALID_CERT_HASH : Client does not match API key",
"domain": "global",
"reason": "invalid"
}
]
}
}
400
2020-12-12 18:23:56.998 15226-15226/com.example.proj1 E/zzf: Failed to get reCAPTCHA token - calling backend without app verification
2020-12-12 18:23:57.660 15226-15263/com.example.proj1 E/FirebaseAuth: [SmsRetrieverHelper] SMS verification code request failed: unknown status code: 17093 null
help.....
solved the problem by redoing the whole thing.
the problem was i was also integrating gmail login in my android app. so i think the credentials for both services were clashing. i removed both things first. then created firebase project did whole thing for otp authorisation, enabled phone auth and voila the otp service was working.
then for gmail login i used the same fire base project and enabled google auth for that and this service also started working.
the problem was i think i used firebase project for otp and google cloud project for gmail. i think these clashed and i got this error.
if you need any more help let me know.

TaskQueueSample.java : Code 403

I am trying to make the sample works so here is the code :
Sample Code
The documentation for the installation is there:
Installation documentation
I had a little problem on the step:
Click on "API Access", and then on "Create an OAuth 2.0 Client
ID...". Enter a product name and click "Next".
The UI of the console has been upgraded probably so I use those data for the authentication in the console:
Then I run the program and it brings me to the webpage to allow the app and then i got the following error message in the console:
403 Forbidden
{
"code" : 403,
"errors" : [ {
"message" : "you are not allowed to make this api call"
} ],
"message" : "you are not allowed to make this api call"
}
My queue.xml ACL is set with the email i used to authenticate
Why don't you use the native TaskQueue-API from the GAE Java SDK? You don't need to set up credentials, connection, ... .
You can see an example on the GAE Docs - here a Pull Queue, but you can also use a Push Queue if you want (an example is also in the GAE Docs).
Which one of the examples do you want to launch on the google app engine? On your posted link are many examples available :) . Tell me if you really want to use the Google-API to access the TaskQueues.

Unable to access user's profile from Google Plus

I am using Scribe-Java to connect to Google plus using OAuth2. I am able to authenticate my application and obtain user's permission, but when I try to access anything other than userinfo, I am getting this Exception.
403
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "accessNotConfigured","message": "Access Not Configured"
}
],
"code": 403,
"message": "Access Not Configured"
}
}
I have set the scope of my application as https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/userinfo.profile and to access user's profile I am using this url:
https://www.googleapis.com/plus/v1/people/{userid}/activities/public
Can you tell me what I am doing wrong? Is there some other scope that I need to use here to access the Profile?
1) Visit the Google APIs console:
http://code.google.com/apis/console
2) Go to the 'Services' page.
3) Enable the Google+ API by switching it to On
I got the same error in PHP using HybridAuth:
I had to activate the following in the Google Developers Console in APIs & Auth -> APIs
Contacts API
Google+ API
See also the discussion at http://hybridauth.sourceforge.net/userguide/IDProvider_info_Google.html

Categories