@revant_one This is the python code that I have.
def index(request):
from rauth import OAuth2Service
frappe_oauth_server = OAuth2Service(client_id="19ee6f84cb",
client_secret=None,
name="test",
authorize_url="http://192.168.2.33/api/method/frappe.integrations.oauth2.authorize",
access_token_url="http://192.168.2.33/api/method/frappe.integrations.oauth2.get_token",
base_url="http://192.168.2.33/api/resource/")
redirect_uri = 'http://127.0.0.1:8000'
params = {'scope': 'openid all', 'response_type': 'code', 'redirect_uri': redirect_uri}
url = frappe_oauth_server.get_authorize_url(**params)
code = request.GET.get('code')
data = {'code': code, 'grant_type': 'authorization_code', 'redirect_uri': redirect_uri}
session = frappe_oauth_server.get_auth_session(data=data, decoder=json.loads)
date_dict = {'url': url, 'id': code}
return render(request, 'DjangoTest/index.html', context=date_dict)
This is the error:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/?code=j5tSHyIj9oCctVRwPOCJijKTTvvnnM
Django Version: 1.11.3
Python Version: 3.6.1
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'DjangoTest.apps.DjangotestConfig']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py" in raw_decode
355. obj, end = self.scan_once(s, idx)
During handling of the above exception (0), another exception occurred:
File "/Users/aldoec/.virtualenvs/DjangoTest/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
41. response = get_response(request)
File "/Users/aldoec/.virtualenvs/DjangoTest/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "/Users/aldoec/.virtualenvs/DjangoTest/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/aldoec/PycharmProjects/DjangoT/DjangoTest/views.py" in index
33. session = frappe_oauth_server.get_auth_session(data=data, decoder=new_decoder)
File "/Users/aldoec/.virtualenvs/DjangoTest/lib/python3.6/site-packages/rauth/service.py" in get_auth_session
556. session = self.get_session(self.get_access_token(method, **kwargs))
File "/Users/aldoec/.virtualenvs/DjangoTest/lib/python3.6/site-packages/rauth/service.py" in get_access_token
542. access_token, = process_token_request(r, decoder, key)
File "/Users/aldoec/.virtualenvs/DjangoTest/lib/python3.6/site-packages/rauth/service.py" in process_token_request
20. data = decoder(r.content)
File "/Users/aldoec/PycharmProjects/DjangoT/DjangoTest/views.py" in new_decoder
13. return json.loads(payload.decode('utf-8'))
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/__init__.py" in loads
354. return _default_decoder.decode(s)
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py" in decode
339. obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/json/decoder.py" in raw_decode
357. raise JSONDecodeError("Expecting value", s, err.value) from None
Exception Type: JSONDecodeError at /
Exception Value: Expecting value: line 1 column 1 (char 0)