Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tw.get_access_token not working #4

Open
gorodscy opened this issue Jan 11, 2018 · 2 comments
Open

tw.get_access_token not working #4

gorodscy opened this issue Jan 11, 2018 · 2 comments

Comments

@gorodscy
Copy link

Calling this method gives me back an error:

OAuth2::Error - unauthorized: Full authentication is required to access this resource
{"error":"unauthorized","error_description":"Full authentication is required to access this resource"}

I'm using it like described in the README:

tw = TransferWise::OAuth.new(transferwise_client_id, transferwise_client_secret)

...
# got the code PS: I made sure I'm using the same redirect_url
...

token = tw.get_access_token(code, transferwise_redirect_url)

Please let me know if there's any other information you need.

@gorodscy
Copy link
Author

for reference, using Net::HTTP it worked:

uri = URI.parse("https://test-api.transferwise.com/oauth/token")
      request = Net::HTTP::Post.new(uri)
      request.basic_auth(transferwise_client_id, transferwise_client_secret)
      request.body = "grant_type=authorization_code&client_id=#{transferwise_client_id}&code=#{code}&redirect_uri=#{redirect_url}"

      req_options = {
        use_ssl: uri.scheme == "https",
      }

      response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
        http.request(request)
      end
      token = JSON.parse(response.body)

@gorodscy
Copy link
Author

I solved the issue. My oauth2 gem was on version 0.6.1
upgraded to version 1.4.0 fixed this issue.
However, the gemspec still allows it:

spec.add_runtime_dependency("oauth2".freeze, ["< 2.0", ">= 0.5.0"])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant