Skip to content

Unauthorized: Unauthorized /oauth2/callback #344

@Blaygh

Description

@Blaygh

I have been trying to configure my app to use this package but I have an error I can't seem fix.

Django version 5.0.7

I keep getting an 2024-07-18 15:19:30,444: Unauthorized: /oauth2/callback error. When I review sign-in attempts in Azure I see the status to be success. The app is deployed in python anywhere, below is my setting in django.

    'AUDIENCE': client_id,
    'CLIENT_ID': client_id,
    'CLIENT_SECRET': client_secret,
    'CLAIM_MAPPING': {'first_name': 'given_name',
                      'last_name': 'family_name',
                      'email': 'upn'},
    'GROUPS_CLAIM': 'roles',
    'MIRROR_GROUPS': True,
    'USERNAME_CLAIM': 'upn',
    'TENANT_ID': tenant_id,
    'RELYING_PARTY_ID': client_id,
    'LOGIN_EXEMPT_URLS': [
        '^$',
        '^receiver/',
    ],
}

LOGIN_URL = 'django_auth_adfs:login'
LOGOUT_URL = 'django_auth_adfs:logout'
LOGIN_REDIRECT_URL = '/admin/'
REDIRECT_URL = 'django_auth_adfs:callback'

Below is the error logs

2024-07-18 14:41:15,507: operating mode:         openid_connect
2024-07-18 14:41:15,507: authorization endpoint: https://login.microsoftonline.com/6b4be17d-a23f-402b-aa40-f7a55e4e9ef3/oauth2/author
ize
2024-07-18 14:41:15,507: token endpoint:         https://login.microsoftonline.com/6b4be17d-a23f-402b-aa40-f7a55e4e9ef3/oauth2/token
2024-07-18 14:41:15,507: end session endpoint:   https://login.microsoftonline.com/6b4be17d-a23f-402b-aa40-f7a55e4e9ef3/oauth2/logout
2024-07-18 14:41:15,507: issuer:                 https://sts.windows.net/6b4be17d-a23f-402b-aa40-f7a55e4e9ef3/
2024-07-18 14:41:15,508: msgraph endpoint:       graph.microsoft.com
2024-07-18 14:41:15,789: Unauthorized: /oauth2/callback
2024-07-18 14:45:23,061: Unauthorized: /oauth2/callback

Also below is the redirect url in python Azure
https://me.pythonanywhere.com/oauth2/callback

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions