Hi team,
I’ve been working on integration tests, with Auht0 and a Django application.
To get started, I used the tutorial provided by the Auth0 team.
Everything looked to work fine, except for the fact that the django views were not returning the correct URL.
So, I made the following changes and the integration seemed to work.
ON DJANGO VIEWS
I basically changed the way the functions return URLS, to prevent them from returning 127 . . .
How it was
def login(request):
return oauth.auth0.authorize_redirect(
request, request.build_absolute_uri(reverse("callback"))
)
def callback(request):
token = oauth.auth0.authorize_access_token(request)
request.session["user"] = token
return redirect(request.build_absolute_uri(reverse("index")))
def logout(request):
request.session.clear()
return redirect(
f"https://{settings.AUTH0_DOMAIN}/v2/logout?"
+ urlencode(
{
"returnTo": request.build_absolute_uri(reverse("index")),
"client_id": settings.AUTH0_CLIENT_ID,
},
quote_via=quote_plus,
),
)
How is now
def auth_login(request):
return oauth.auth0.authorize_redirect(
request, 'https://mydomain.com.br/callback/'
)
def callback(request):
token = oauth.auth0.authorize_access_token(request)
request.session["user"] = token
return redirect('https://mydomain.com.br/')
def auth_logout(request):
request.session.clear()
return redirect(
f"https://{settings.AUTH0_DOMAIN}/v2/logout?"
+ urlencode(
{
"returnTo": 'https://mydomain.com.br',
"client_id": settings.AUTH0_CLIENT_ID,
},
quote_via=quote_plus,
),
)
The problem now is that after the login, a 404 returns. Any other page I try to access after the login request returns the same thing.
If I use the logout method, the session ends successfully.
The request is being made on ip 127… and I believe it should be passing the URL sent, and not this ‘LOCAL ONE’, in the view.
Does anyone have any idea how I can fix this to finish this testing stage?