I'm trying to use Google's API to sign up and log in users to my rails webapp. I've been playing around with the authentication, but I'm getting stuck on this error after I get the authorization code.
Here's what I'm trying to do:
path = Rails.root.to_s + PATH_TO_JSON_FILENAME_FROM_GOOGLE_API
client_secrets = Google::APIClient::ClientSecrets.load(path)
auth_client = client_secrets.to_authorization
auth_client.update!(
:scope => 'https://www.googleapis.com/auth/drive.metadata.readonly',
:redirect_uri => REDIRECT_URI
)
auth_client.code = ACCESS_CODE_RETURNED_BY_GOOGLE_WHEN_USER_LOGS_IN
auth_client.fetch_access_token!
A few questions:
- All I really want to be able to pull is the users name, and their email address. I'm unclear on what the proper value for
:scope
should be. For the
redirect_uri
I'm setting it to one of the redirect uri's that are in my Google API console. Something along the lines ofhttp://localhost:3000/auth/callback
. Despite this, I'm getting the following json response:{ "error" : "redirect_uri_mismatch" }
Thoughts on what I might be doing wrong here?