Trying to access Google Cloud IoT API - POST method -
- Used this as reference as I am new to google cloud - https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/iot/api-client/manager
- I have created a Spring Boot Application and an account with google.
- Verified google credentials through CLI & a project ID has been linked with my project.
- I have checked the permissions assigned to my account it was Owner/admin.
- I have checked the quota allocated- haven't exceeded the amount.
I am trying to create a registry through the command line from my Spring Boot Application, but it is throwing the below error :
Exception in thread "main" com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden POST https://cloudiot.googleapis.com/v1/projects/null/locations/us-central1/registries { "code": 403, "errors": [ { "domain": "usageLimits", "message": "Cloud IoT API has not been used in project xxxxxxxxxx90 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/cloudiot.googleapis.com/overview?project=xxxxxxxxxx90 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.", "reason": "accessNotConfigured", "extendedHelp": "https://console.developers.google.com" } ], "message": "Cloud IoT API has not been used in project xxxxxxxxxx90 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/cloudiot.googleapis.com/overview?project=xxxxxxxxxx90 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.", "status": "PERMISSION_DENIED" }
I have enabled the Cloud IoT API, still the error is thrown.
Also, on the console log, I can see the following suggestion :
Your application has authenticated using end user credentials from Google Cloud SDK. We recommend that most server applications use service accounts instead. If your application continues to use end user credentials from Cloud SDK, you might receive a "quota exceeded" or "API not enabled" error. For more information about service accounts, see https://cloud.google.com/docs/authentication/.
- I have created a service account & activated it through CLI as well. It isn't helping.
Any suggestion, fresh perspective is highly appreciated. Please do let me know if any other info needs to be added. Thanks in advance.
gcloud init. - Gabe Weiss