Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django REST framework integration issues #265

Closed
estherjk opened this issue Aug 4, 2018 · 4 comments
Closed

Django REST framework integration issues #265

estherjk opened this issue Aug 4, 2018 · 4 comments

Comments

@estherjk
Copy link

estherjk commented Aug 4, 2018

Hi, I'm currently trying to get the Django REST framework integration working and get this when I access my API (using the browsable API):

HTTP 401 Unauthorized
Allow: GET, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept
WWW-Authenticate: Bearer realm="api"

{
    "detail": "Authentication credentials were not provided."
}

Here's what the relevant (I think) sections in settings.py look like:

INSTALLED_APPS = [
    'home.apps.HomeConfig',
    'accounts.apps.AccountsConfig',
    'api.apps.ApiConfig',
    'django.contrib.admin',
    'django.contrib.auth',
    'mozilla_django_oidc',  # Load after auth
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
]

AUTHENTICATION_BACKENDS = (
    'mozilla_django_oidc.auth.OIDCAuthenticationBackend',

    # Basic authentication backend that checks the Django users database and queries the built-in permissions
    # 'django.contrib.auth.backends.ModelBackend',
)

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'mozilla_django_oidc.contrib.drf.OIDCAuthentication',
    ),
    'DEFAULT_PERMISSION_CLASSES': (
        'rest_framework.permissions.IsAuthenticated',
    )
}

Is there anything else that I should be configuring? Any help would be appreciated.

Also, for reference, using Python 3.6.5 with the following versions for Django, etc.:

Django==2.0.7
djangorestframework==3.8.2
mozilla-django-oidc==1.1.0
@estherjk
Copy link
Author

I think I figured it out... need to use session authentication for the browsable API. Similar to this issue.

@rehmat11872
Copy link

same issue how i can tickle this issue

@suyogbargule
Copy link

same problem

@VishKhandelwal
Copy link

Same Problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants