Ошибка NoReverseMatch при попытке использовать Google OAuth 2.0
Я застрял на [Шаг 2: Перенаправление на сервер Google OAuth 2.0][1] из Using OAuth 2.0 for Web Server Applications
Руководства Google.
Я зарегистрировал свое приложение, получил идентификатор клиента и секрет, и имею те же авторизованные URI перенаправления в Google Developer Console, что и в моем приложении.
Я получаю эту ошибку, когда пытаюсь перенаправить пользователя на форму согласия google.
NoReverseMatch at /login/
Reverse for '?response_type=code&client_id=&redirect_uri=http%3A%2F%2Flocalhost%3A8000%2F&scope=profile+openid+email&state=NZkfzNYMEqWIY1YG07eFxE6VL2YSip&access_type=offline&prompt=consent&include_granted_scopes=true'
вот функция, которая выдает ошибку при возврате:
import google_auth_oauthlib.flow
from django.shortcuts import redirect
def authorize():
"""
Set authorization parameters and redirect to Google's OAuth 2.0
server to prompt user for consent
"""
flow = google_auth_oauthlib.flow.Flow.from_client_secrets_file(
client_config=client_secret.json,
scopes=['profile', 'openid', 'email']
)
# Indicate where the API server will redirect the user after the user completes
# the authorization flow. The redirect URI matches one of the authorized
# redirect URIs for the OAuth 2.0 client in the API Console.
flow.redirect_uri = 'http://localhost:8000/'
authorization_url, state = flow.authorization_url(
access_type='offline',
prompt='consent',
include_granted_scopes='true')
return redirect(authorization_url)