Chau Loi
Chau Loi

Reputation: 1225

How to config Bearer Token when making a GET request?

Here is the Bearer Token in Postman:

enter image description here

Here is what I do in code:

url_apollo = https://
params_apollo = {
    'ID': 123,
}

Here is the requests that I made:

r_apollo = requests.get(url = url_apollo, 
                        params = params_apollo, 
                        headers={'Authorization': 'Bearer ' + 'Token'})

simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Upvotes: 0

Views: 104

Answers (1)

Klatten
Klatten

Reputation: 312

You could do it like this:

url_apollo = https://
params_apollo = {'ID': 123}
headers = {'Authorization': 'Bearer YOURTOKENHERE'}

r_apollo = requests.get(url=url_apollo, 
                        params=params_apollo, 
                        headers=headers)

The reason why you get that error message is within the "params_apollo" variable. Since "ID" is the last line in the JSON, the comma after the value is incorrect and raises a JSONDecodeError.

Upvotes: 1

Related Questions