You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! Thanks for your work!
But I need help of community.
In my Django project with django-rest-framework, we use JWT authentication and want to implement the social login by google. So, I installed and configured drf-social-oauth2 with backend google-oath2 in the project as shown in docs.
And if I follow as per our requirements we need the user to redirect to google-oauth2 page and login with credentials and also our app to access data and create user. This achieved by http://localhost:8000/sign_in/google API it redirect to http://localhost:8000/complete/google-oauth2/ with necessary parameters and social user with django user created and redirect to LOGIN_REDIRECT_URL with session authentication.
This part is working and user is created successfully.
Redirection is working fine. Reverse redirection with user creation works fine too. But how do I send data to the api in the documentation to get an authorization token on the server? (We do not have session authorization).
Please need your help to understand the process, I read a lot and watched tutorials but didn't get as expected.
If you need any detail please ask.
The text was updated successfully, but these errors were encountered:
Hi, If I understand your question correctly, you want to get specific data from the Google API. For that this page help you , but it is for flask and you must change it for DRF.
and this link help you as well and this function:
import google_auth_oauthlib.flow
import requests
from styleguide_example.core.exceptions import ApplicationError
class GoogleSdkLoginFlowService:
# Here we have the implementation of get_authorization_url
def get_tokens(self, *, code: str, state: str) -> GoogleAccessTokens:
redirect_uri = self._get_redirect_uri()
client_config = self._generate_client_config()
flow = google_auth_oauthlib.flow.Flow.from_client_config(
client_config=client_config, scopes=self.SCOPES, state=state
)
flow.redirect_uri = redirect_uri
access_credentials_payload = flow.fetch_token(code=code)
if not access_credentials_payload:
raise ApplicationError("Failed to obtain tokens from Google.")
google_tokens = GoogleAccessTokens(
id_token=access_credentials_payload["id_token"],
access_token=access_credentials_payload["access_token"]
)
return google_tokens
Hi! Thanks for your work!
But I need help of community.
In my Django project with django-rest-framework, we use JWT authentication and want to implement the social login by google. So, I installed and configured drf-social-oauth2 with backend google-oath2 in the project as shown in docs.
settings.py
urls.py
And now the question itself.
How to implement redirection with the necessary data after user authorization on an external resource?
I have a user's entry point with a redirect to google authorization
method
And if I follow as per our requirements we need the user to redirect to google-oauth2 page and login with credentials and also our app to access data and create user. This achieved by
http://localhost:8000/sign_in/google
API it redirect tohttp://localhost:8000/complete/google-oauth2/
with necessary parameters and social user with django user created and redirect to LOGIN_REDIRECT_URL with session authentication.This part is working and user is created successfully.
Redirection is working fine. Reverse redirection with user creation works fine too. But how do I send data to the api in the documentation to get an authorization token on the server? (We do not have session authorization).
Please need your help to understand the process, I read a lot and watched tutorials but didn't get as expected.
If you need any detail please ask.
The text was updated successfully, but these errors were encountered: