Added in the global configuration "oauth2_provider. Contrib. Rest_framework. OAuth2Authentication",
This authentication is skipped when API requests such as headers do not transmit token
def authenticate(self, request):
"""
Returns two-tuple of (user, token) if authentication succeeds,
or None otherwise.
"""
oauthlib_core = get_oauthlib_core()
valid, r = oauthlib_core.verify_request(request, scopes=[])
if valid:
return r.user, r.access_token
request.oauth2_error = getattr(r, "oauth2_error", {})
return None
Django 2.1 djangorestframework 3.8.2 django-rest-framework-social-oauth2 1.1.0
Added in the global configuration "oauth2_provider. Contrib. Rest_framework. OAuth2Authentication", This authentication is skipped when API requests such as headers do not transmit token
Authentication is skipped when valid is false
advice raise exceptions.AuthenticationFailed