estoy intentando conectarme a una API que usa Oauth2, y necesito pasarle un code, pero no sé cual es la forma correcta de hacerlo. Tengo lo siguiente:
require "oauth2"
# Create the client with your credentials
UID = "XXXX"
SECRET = "XXXX"
client = OAuth2::Client.new(UID, SECRET, site: "https://XXXX")
# Token credentials
redirect_uri = "https://XXXX/oauth/authorize?client_id=XXXX&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Ftools.html&response_type=code"
token = client.auth_code.get_token('authorization_code_value', redirect_uri: redirect_uri, headers: { 'Accept' => 'application/json' })
puts token
El error que me devuelve es el siguiente,
invalid_grant: The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client. (OAuth2::Error)
{"error":"invalid_grant","error_description":"The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client."}