wagnerdelima / drf-social-oauth2

drf-social-oauth2 makes it easy to integrate Django social authentication with major OAuth2 providers, i.e., Facebook, Twitter, Google, etc.
https://drf-social-oauth2.readthedocs.io/en/latest/
MIT License
271 stars 34 forks source link

AccessDeniedError at /auth/convert-token (access_denied) Your credentials aren't allowed <oauthlib.Request SANITIZED> #130

Closed Nizzy94 closed 2 years ago

Nizzy94 commented 2 years ago

Describe the bug I have been able to set drf-social-oauth2 and created an app in the Django auth tool kit. everything works out with getting the credentials from Google but when I send the details to the convert-token endpoint, it gives me the AccessDeniedError.

It use to work with the old google API (gapi) system but I was prompted it'll be depreciated soon so I switched to the GSI and this is what I'm getting.

To Reproduce Just set up a Django project and install drf-social-oauth2 Go to https://developers.google.com/oauthplayground/ use the playground to generate a token and use that token to access /auth/convert-token

Expected behavior An access_token and a refresh_toke are supposed to be returned as the response

Screenshots

Screenshot 2022-06-10 at 1 49 32 PM
Nizzy94 commented 2 years ago

I have found a solution to my problem. Apparently I was supposed to convert that jwt token to get an access token from google, then send the access token to the backend for verification. But then I ran into another issue which I'll put up. when a user is logging in for the first time, it works fine. But after logging out, if same user tries to login again, I get another error: BadHeaderError("Header values can't contain newlines (got %r)" % value)

saumojit commented 10 months ago

How did you solve this (base)

C:\Users\hp>curl -X POST -d "grant_type=convert_token&client_id=11&client_secret=11&backend=google-oauth2&token=4/0AfJohXmee34GJDRqpwxARFfWjkL9QjffY1VFnCDC382q4YA1h8G3MdZsYevCsBJO98WbpA" http://localhost:8000/auth/convert-token

Output : {"error":"access_denied","error_description":"Your credentials aren't allowed"}