Social-auth-app-django Google Login and React-Native

< <

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [BASE_DIR / 'templates']
        ,
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'social_django.context_processors.backends',
                'social_django.context_processors.login_redirect',
            ],
        },
    },
]

AUTHENTICATION_BACKENDS = (
    'social_core.backends.google.GoogleOAuth2',
    'django.contrib.auth.backends.ModelBackend',
)

for key in ['GOOGLE_OAUTH2_KEY',
            'GOOGLE_OAUTH2_SECRET', ]:

    exec("SOCIAL_AUTH_{key} = os.environ.get('{key}')".format(key=key))

SOCIAL_AUTH_LOGIN_REDIRECT_URL  = 'http://localhost:19006/'
<
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('oauth/', include('social_django.urls', namespace='social')),
]
<
const signInGoogle = async () => {
  const redirectUri = AuthSession.makeRedirectUri({
    useProxy: true,
  });
  const result = await WebBrowser.openAuthSessionAsync(
    `http://localhost:8000/oauth/login/google-oauth2?next=${redirectUri}`,
    redirectUri
  );
  console.log(result);
};
<
Вернуться на верх