juanifioren / django-oidc-provider

OpenID Connect and OAuth2 provider implementation for Djangonauts.
http://django-oidc-provider.readthedocs.org
MIT License
423 stars 238 forks source link

Invalid redirect_uri error #121

Closed spinza closed 8 years ago

spinza commented 8 years ago

I'm testing this out with Rocket.Chat as a client.

I keep getting invalid redirect_uri errors but can't figure out the exact reason. There are 3 or 4 reasons for the error and I don't know which it is triggering as the displayed error is generic but the code seems to log the exact reason.

How do I activate the logging (installed via pip)? I've set logging to debugging for the example app but this doesn't carry through to the pip module it seems? Can the error displayed in the browser be more descriptive? Similar to the logging.

Probably my noob ness.

juanifioren commented 8 years ago

Hi @spinza


If you have a "Redirect URI Error" what you can do is checking the url of the redirect that rocket.chat is doing. Then extract the redirect_uri part, url-decode it and add it into the redirect URIs field using the admin site.

Example redirect:

/openid/authorize?client_id=123&redirect_uri=http%3A%2F%2Fexample.com%2Fsomething%2F&response_type=code&scope=openid%20profile%20email&state=abcdefgh

For logging you can add oidc_provider into your custom django logging setting.

Example LOGGING configuration:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': True,
    'formatters': {
        'simple': {
            'format': '[%(levelname)s] %(asctime)s %(message)s',
            'datefmt': '%H:%M',
        },
    },
    'filters': {
        'require_debug_true': {
            '()': 'django.utils.log.RequireDebugTrue',
        },
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        },
    },
    'handlers': {
        'console': {
            'level': 'INFO',
            'class': 'logging.StreamHandler',
            'filters': ['require_debug_true'],
            'formatter': 'simple',
        },
        'mail_admins': {
            'level': 'ERROR',
            'class': 'django.utils.log.AdminEmailHandler',
            'filters': ['require_debug_false'],
        },
    },
    'loggers': {
        'django': {
            'handlers': ['console'],
            'propagate': True,
        },
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': False,
        },
        'oidc_provider': {
            'handlers': ['console'],
            'level': 'DEBUG',
            'propagate': True,
        },
    },
}