Closed juanthehuman closed 1 year ago
same issue here on calling `convert-token'
This is not replicable. Please add more information.
React frontend side library used is @react-oauth/google
.
console.log(response)
var decoded = jwt_decode(response.credential);
console.log(decoded)
googleBackCall(decoded,response)
}
<GoogleOAuthProvider clientId="xxxxxxxxxxxxx.apps.googleusercontent.com"> //I put actual double checked client id
<GoogleLogin
onSuccess={responseGoogle}
onFailure={() => console.log("login cancled")}
onError={() => {
console.log('Login Failed');
}}
/>
</GoogleOAuthProvider>```
onSuccess an API call is made to the Django backend to get backend application token,
`js import axios from 'axios'
const googleLogin = (accessToken,response) => {
console.log(accessToken)
axios.post('http://localhost:8000/auth/convert-token',{
token: accessToken.jti,
email:accessToken.email,
first_name:accessToken.given_name,
last_name:accessToken.family_name,
backend: 'google-oauth2',
grant_type: 'convert_token',
client_id: 'LFG6fbrrKKowufV4Bm6e5JFGGw3xLdcnktG5kg',
client_secret: 'MeKZwqp9f5iBD1sncIRb7r4hrYCvl51y2Tb1oQezuxO04Cb0sJAtEazQu5yYiqUx83v7zZhDzVquBTw2GkY6LfvVqNxufPSVhHm4jTGIdclqRGu0Ow8lLO0wu3bmV7'
})
.then((res)=>{
localStorage.setItem('access_token',res.data.access_token)
localStorage.setItem('refresh_token',res.data.refresh_token)
})
}
export default googleLogin`
backend social login is handled by `drf_social_oauth2`.
The expected behavior is on login from the frontend in Google, an user should be created in the backend.
I have verified the models, serializers, and other backend stuff including settings.py
The error is the response of API with the status `400 Bad Request` and response `{error: "access_denied", error_description: "Your credentials aren't allowed"}`
Payload is something like this
![image](https://github.com/wagnerdelima/drf-social-oauth2/assets/63193129/d39d3fa1-39e0-454d-8dbb-93212fcec3ca)
-- google["credential"] ( JWT Token )
curl -X POST -d "grant_type=convert_token&client_id=11&client_secret=11&backend=google-oauth2&token=
I have google jwt token which I am passing above curl command , but it is giving the same error as above -- {"error":"access_denied","error_description":"Your credentials aren't allowed"} on drf-social-auth2.
Same token when i use with from google.oauth2 import id_token , it works good.
requested to provide a quick resolution on this
POSTMAN
POST http://localhost:8000/auth/convert-token Body x-www-form-urlencoded client_id=
client_secret=
token=<(jwt credential from the frontend)>
grant_type=convert_token
backend=google-oauth2