OneDrive / onedrive-sdk-python

OneDrive SDK for Python! https://dev.onedrive.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JSONDecodeError: Expecting value: line 3 column 1 (char 4)

ashish453 opened this issue · comments

when I Run this :

import onedrivesdk
from onedrivesdk.helpers import GetAuthCodeServer
from onedrivesdk.helpers.resource_discovery import ResourceDiscoveryRequest

redirect_uri = 'http://localhost:8080'
client_id = "**********"
client_secret = "************"
discovery_uri = 'api.office.com/discovery'
auth_server_url = 'login.microsoftonline.com/common/oauth2/authorize'
auth_token_url = 'http://login.microsoftonline.com/common/oauth2/token?'

http = onedrivesdk.HttpProvider()
auth = onedrivesdk.AuthProvider(http, client_id,
                                auth_server_url=auth_server_url,
                                auth_token_url=auth_token_url)
auth_url = auth.get_auth_url(redirect_uri)
print("Paste this in, and copy/paste the thing after 'code='.")
print(auth_url)
code = input('Paste code here: ')
auth.authenticate(code, redirect_uri, client_secret, resource=discovery_uri)

I get an url.I open the url and sign in to my OneDrive for Business account. I did copy all the stuff after code= and paste below

Paste this in, and copy/paste the thing after 'code='.
login.microsoftonline.com/common/oauth2/authorize?client_id=4dca28ce-c82a-42d6-8690-f892663999d7&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A8080
Paste code here: 

I got this error:

Paste this in, and copy/paste the thing after 'code='.
login.microsoftonline.com/common/oauth2/authorize?client_id=4dca28ce-c82a-42d6-8690-f892663999d7&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A8080
Paste code here: AQABAAIAAAAm-06blBE1TpVMil8KPQ41N-w_JLfgB61-UoHEAs9xPfRHOFdPSvuOHs_NTsesCrgUwRP_wV8NeP6fnmhqxJd2Fj01uQk8pfnDo4MjXd4_TrBtdsDF2lhYbKEqTzg-kk2JF8pIsxETwPmsQ9pGQPiN7ZpjptOrzRs0guLQP9rLAs2yPgLMDAFK-1Dcpb6GDPJeexYnsKfmHVFdJpahrAaoO4k2Jikm1ehhfJupqmZ64zbAIlHE95I5oNrxCbFwnxEfKYyJ1a8KwB2G26rC2PQV0K6n_6Nc_M1CWobRJNW-dukBfFw475gUC8pKCTE0eAR1pbseSuQM5UPi8XHXUWIRT4ccqPKjDCclXvDpPrhpp8ONtDGxa2lvM-_DRa39FD5-CAHIyRZ0j1bis6g77aVzsf-R1OIvxZaQwg_t4Ko_MzVj-MOuPV2thUt-n1EYmukueXPpmbnCxnDMvqXfM6WjYLHWrGW_5KEFCq7INx0HlqsdjJ7V3AqTAY20hL4RfWeIUO92GHIuvqlhg6MZdpBzw85BRdXQ54vjQhWktztlLyAA&session_state=e093b529-c981-4e01-b095-8db161662c73
---------------------------------------------------------------------------
JSONDecodeError                           Traceback (most recent call last)
<ipython-input-12-4303e874c9a5> in <module>()
     18 print(auth_url)
     19 code = input('Paste code here: ')
---> 20 auth.authenticate(code, redirect_uri, client_secret, resource=discovery_uri)

3 frames
/usr/lib/python3.6/json/decoder.py in raw_decode(self, s, idx)
    355             obj, end = self.scan_once(s, idx)
    356         except StopIteration as err:
--> 357             raise JSONDecodeError("Expecting value", s, err.value) from None
    358         return obj, end

JSONDecodeError: Expecting value: line 3 column 1 (char 4)

What can I do now?

@ashish453 I've told you how to fix this back in #180, please close this duplicate.
(I really try to keep this repo's issues managable. It means a lot to me for every issue closed, even though I'm not related to Microsoft/OneDrive at all.)