ByteInternet / drf-oidc-auth

OpenID Connect authentication for Django REST Framework
MIT License
113 stars 46 forks source link

simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0) #30

Open Allan-Nava opened 6 years ago

Allan-Nava commented 6 years ago
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
    response = self._get_response(request)
  File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.5/dist-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
    return view_func(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/rest_framework/viewsets.py", line 103, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/rest_framework/views.py", line 483, in dispatch
    response = self.handle_exception(exc)
  File "/usr/local/lib/python3.5/dist-packages/rest_framework/views.py", line 443, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/usr/local/lib/python3.5/dist-packages/rest_framework/views.py", line 471, in dispatch
    self.initial(request, *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/rest_framework/views.py", line 388, in initial
    self.perform_authentication(request)
  File "/usr/local/lib/python3.5/dist-packages/rest_framework/views.py", line 314, in perform_authentication
    request.user
  File "/usr/local/lib/python3.5/dist-packages/rest_framework/request.py", line 222, in user
    self._authenticate()
  File "/usr/local/lib/python3.5/dist-packages/rest_framework/request.py", line 375, in _authenticate
    user_auth_tuple = authenticator.authenticate(self)
  File "/usr/local/lib/python3.5/dist-packages/oidc_auth/authentication.py", line 47, in authenticate
    userinfo = self.get_userinfo(bearer_token)
  File "/usr/local/lib/python3.5/dist-packages/oidc_auth/util.py", line 40, in wrapped
    cached_value = fn(this, *args)
  File "/usr/local/lib/python3.5/dist-packages/oidc_auth/authentication.py", line 74, in get_userinfo
    response = requests.get(self.oidc_config['userinfo_endpoint'],
  File "/usr/local/lib/python3.5/dist-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/python3.5/dist-packages/oidc_auth/authentication.py", line 35, in oidc_config
    return requests.get(api_settings.OIDC_ENDPOINT + '/.well-known/openid-configuration', verify=default_ssl_check).json()
  File "/usr/local/lib/python3.5/dist-packages/requests/models.py", line 892, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/simplejson/__init__.py", line 516, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.5/dist-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/local/lib/python3.5/dist-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

When I add Authorization Bearer and I have this error

Allan-Nava commented 6 years ago

How can I fix this problem?? @koriaf Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/oidc_auth/util.py", line 38, in wrapped cached_value = self.get_from_cache(args) File "/usr/local/lib/python3.5/dist-packages/oidc_auth/util.py", line 29, in get_from_cache return self.cached_values[key] KeyError: (b'eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICI4c2RZTEJsdFVWTjlqcUpBLXFVWHJmUnRkWXFqanRQX0NRUlhDdHZNU1JVIn0.eyJqdGkiOiIzZjZmOGZmYi0wOGVlLTRhNDQtOWI4Ny0wNGIyMGNlNzUyNjUiLCJleHAiOjE1MzA3Nzc1NTYsIm5iZiI6MCwiaWF0IjoxNTMwNzc3MjU2LCJpc3MiOiJodHRwOi8vbG9naW4ubGl2ZXJlcG9ydGVyLmNvbTo4MDgwL2F1dGgvcmVhbG1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iJJdGFsaWEiLCJiaXJ0aGRhdGUiOiIyMDAwLTA2LTIyIiwibmFtZSI6IkFkYW0gTmF2YSIsInByZWZlcnJlZF91c2VybmFtZSI6ImFsbGFubmF2YSIsIm1vYmlsZV9udW1iZXIiOiIzOTMyODY4NjU5NzQiLCJnaXZlbl9uYW1lIjoiQWRhbSIsImZhbWlseV9uYW1lIjoiTmF2YSIsImVtYWlsIjoiYWxsYW4ubmF2YUBpZXMtaXRhbGlhLml0In0.l02qAYB3rWLngXun33jC92Jl9FeChDV606JEm3w2Gs9FD3cBFwSQv7Zgnik8T-trZ_8Byobf_X4j6eZ_7Nw75slKiQfA-_au-iDL893YEtd66cJZH2VbrEo-EWnT-rLfbGt-_nrVbJS3N8w1_WRS-5LNGhfUxHF4IHD5Bu9eAUGSlWDsDVmlevV76Wzbrgt4x9JpRyK4V6GoKsKyJUJQvS1EPmFr84B9sgo74WA9eEEm5jhxuyb_85akSMDo-KalRi6jH2gHC4dFHuaYmryA2yh42Nx1i27RuCFOT6CiZLkn-aAmdsYxQw47VCdivSaUku83tUpoBrNwGXiAa_017A',)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py", line 41, in inner response = get_response(request) File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py", line 249, in _legacy_get_response response = self._get_response(request) File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request) File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, callback_kwargs) File "/usr/local/lib/python3.5/dist-packages/django/views/decorators/csrf.py", line 58, in wrapped_view return view_func(*args, *kwargs) File "/usr/local/lib/python3.5/dist-packages/rest_framework/viewsets.py", line 103, in view return self.dispatch(request, args, kwargs) File "/usr/local/lib/python3.5/dist-packages/rest_framework/views.py", line 483, in dispatch response = self.handle_exception(exc) File "/usr/local/lib/python3.5/dist-packages/rest_framework/views.py", line 443, in handle_exception self.raise_uncaught_exception(exc) File "/usr/local/lib/python3.5/dist-packages/rest_framework/views.py", line 471, in dispatch self.initial(request, *args, *kwargs) File "/usr/local/lib/python3.5/dist-packages/rest_framework/views.py", line 388, in initial self.perform_authentication(request) File "/usr/local/lib/python3.5/dist-packages/rest_framework/views.py", line 314, in perform_authentication request.user File "/usr/local/lib/python3.5/dist-packages/rest_framework/request.py", line 222, in user self._authenticate() File "/usr/local/lib/python3.5/dist-packages/rest_framework/request.py", line 375, in _authenticate user_auth_tuple = authenticator.authenticate(self) File "/usr/local/lib/python3.5/dist-packages/oidc_auth/authentication.py", line 47, in authenticate userinfo = self.get_userinfo(bearer_token) File "/usr/local/lib/python3.5/dist-packages/oidc_auth/util.py", line 40, in wrapped cached_value = fn(this, args) File "/usr/local/lib/python3.5/dist-packages/oidc_auth/authentication.py", line 74, in get_userinfo response = requests.get(self.oidc_config['userinfo_endpoint'], File "/usr/local/lib/python3.5/dist-packages/django/utils/functional.py", line 35, in get res = instance.dict[self.name] = self.func(instance) File "/usr/local/lib/python3.5/dist-packages/oidc_auth/authentication.py", line 35, in oidc_config return requests.get(api_settings.OIDC_ENDPOINT + '/.well-known/openid-configuration', verify=default_ssl_check).json() File "/usr/local/lib/python3.5/dist-packages/requests/models.py", line 892, in json return complexjson.loads(self.text, **kwargs) File "/usr/local/lib/python3.5/dist-packages/simplejson/init.py", line 516, in loads return _default_decoder.decode(s) File "/usr/local/lib/python3.5/dist-packages/simplejson/decoder.py", line 370, in decode obj, end = self.raw_decode(s) File "/usr/local/lib/python3.5/dist-packages/simplejson/decoder.py", line 400, in raw_decode return self.scan_once(s, idx=_w(s, idx).end()) simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0)