OAuth error when starting rails server in development
rorykoehler opened this issue · 1 comments
I get
/gems/signet-0.8.1/lib/signet/oauth_2/client.rb:988:in `fetch_access_token': Authorization failed. Server message: (Signet::AuthorizationError)
{
"error": "invalid_grant",
"error_description": "Bad Request"
}
when trying to start rails server while running emulator in development. I also get the following:
$ bundle exec activejob-google_cloud_pubsub-worker --project_id=dummy
Note: Google::Cloud::Logging is disabled because it failed to authorize with the service. (Authorization failed. Server message:
{
"error": "invalid_grant",
"error_description": "Bad Request"
}) Falling back to the default Rails logger.
Note: Google::Cloud::Debugger is disabled because it failed to authorize with the service. (Authorization failed. Server message:
{
"error": "invalid_grant",
"error_description": "Bad Request"
})
Note: Google::Cloud::ErrorReporting is disabled because it failed to authorize with the service. (Authorization failed. Server message:
{
"error": "invalid_grant",
"error_description": "Bad Request"
})
Note: Google::Cloud::Trace is disabled because it failed to authorize with the service. (Authorization failed. Server message:
{
"error": "invalid_grant",
"error_description": "Bad Request"
})
I guess I missed a step related to auth, however when I read the official docs they say no credentials etc necessary when using app engine. I also assumed the emulator wouldn't need auth? What am I missing?
I solved my problem by creating a service account key and referencing the json file as per your example. I'm still not exactly sure why this is necessary for using the pubsub simulator?
For anyone else wondering you can find the instruction for creating the credentials json file here: https://cloud.google.com/docs/authentication/production#obtaining_and_providing_service_account_credentials_manually