Skip to content

How Consent Form is Working? #1441

@johnnyAnd

Description

@johnnyAnd

I have the following set in my settings.py

OAUTH2_PROVIDER = {
    'ACCESS_TOKEN_EXPIRE_SECONDS': 36000,
    'AUTHORIZATION_CODE_EXPIRE_SECONDS': 600,
    # 'OAUTH2_BACKEND_CLASS': 'oauth2_provider.oauth2_backends.JSONOAuthLibCore',
    'SCOPES': {
        'read': 'Read scope',
        'write': 'Write scope',
    },
    'PKCE_REQUIRED': False,  # Ensure PKCE is required as per security best practices
}

But I don't see the Authorize Consent Form every time I try to Log in via OAuth. What is the exact thing in the Database of Cache that is stopping the consent form from appearing again? I want to show the consent form for Authorization, each time the user log in via OAuth.

Activity

n2ygk

n2ygk commented on Jul 25, 2024

@n2ygk
Contributor
jaap3

jaap3 commented on Aug 28, 2024

@jaap3

There is a setting REQUEST_APPROVAL_PROMPT, which controls when the consent screen is displayed. Setting this to 'force' will always show the consent screen.

The default is 'auto', meaning DOT will check if there is an active (non-expired) token for request.user with the same client and overlapping scopes as the current authorization request. If such a token exists, consent is automatically granted.

This means that, if the token isn't refreshed, the consent screen wil reappear after ACCESS_TOKEN_EXPIRE_SECONDS (default: 36000, or 10 hours).

jaap3

jaap3 commented on Aug 28, 2024

@jaap3

It seems that you can also use the approval_prompt request parameter (which doesn't seem to be part of the spec).

I'm not sure if DOT supports the prompt=consent which is part of the spec: https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest

jaap3

jaap3 commented on Aug 28, 2024

@jaap3

Turns out REQUEST_APPROVAL_PROMPT defaults to 'force', so now I don't know what to think:

https://github.com/jazzband/django-oauth-toolkit/blob/34912ff53d948831cf4d86f210290b06c04e4d09/oauth2_provider/settings.py#L70

dopry

dopry commented on Nov 2, 2025

@dopry
Member

@johnnyAnd the specs dont' always require the consent form to be displayed. If you think you are experiencing a bug opn a new issue with the details to reproduce it and hopefully someone will take the time to confirm and fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jaap3@dopry@n2ygk@johnnyAnd

        Issue actions

          How Consent Form is Working? · Issue #1441 · django-oauth/django-oauth-toolkit