I'm using Ruby on Rails for get a token using Oauth2 for Clio app. So, I install the following gem:
gem 'oauth2'
And this is my code:
client = OAuth2::Client.new(CLIENT_KEY_CLIO, CLIENT_SECRET_CLIO, site: SITE)
token = client.auth_code.get_token(code, :redirect_uri => 'http://127.0.0.1/approval')
return token
Where the variable code
is send by frontend. And is a code that the clio app send when user make a login in his clio account.
But the redirect_uri URL did not exist. However, I created it and the only thing it does is get the code parameter and return it.
Still, it does not work. According to the documentation I can put the default URL that is https://app.clio.com/oauth/approval
but it does not work either. I always have this error:
{
"error": "invalid_grant",
"error_description": "The provided access grant is invalid, expired, or revoked (e.g. invalid assertion, expired authorization token, bad end-user password credentials, or mismatching authorization code and redirection URI)."
}
I remember that this error happened before. But it was solved when the redirect_uri value was changed.
What is wrong with the redirect_uri? Could someone provide me with an example of Oauth2 requests?