Hello I'm trying to setup up an oauth2 webapp (front end written in react, backend in rails). On the front end I'm able to get authenticate and ket my access code, after that through my callback function on redirected to my back server, where I'm trying to exchange my front end code for a token, below is my code on the back end.
I am initializing a new auth_client and it is being updated properly (client_secrets and code). The problem is when I'm requesting my exchange token, it is giving me a
*** Signet::AuthorizationError Exception: Authorization failed. Server message:
{
"error" : "redirect_uri_mismatch"
}
I don't know how to solve that, the redirect address is being loaded from the client_secret, I've confirmed it, I tried to update it again using auth_client.update!, same problems. My routes do exist, tried them, I was using localhost before, but was getting same error, through web search was able to find recommendations of the use of
lvh.me.
I don't know what else to try, I would really appreciate if someone could give me some direction, this is for a capstone project due on Wednesday, and I everything else depends on it...
Thank you in advance for any help ....
require 'google/api_client/client_secrets'
require 'fileutils'
class Api::V1::AuthController < ApplicationController
def create
client_secrets= Google::APIClient::ClientSecrets.load("client_secrets.json")
auth_client = client_secrets.to_authorization
auth_client.update!(
:additional_parameters => {
"access_type" => "offline", # offline access
"include_granted_scopes" => "true" # incremental auth
}
)
auth_client.code = params["code"]
result = auth_client.fetch_access_token!
end
def show
byebug
end
end
client_secrets.json
{
"web": {
"client_id":
"<MY_CLIENT_ID",
"project_id": "storied-pixel-191717",
"client_secret": "<MY_CLIENT_SECRET>",
"scope":
}
}