Pankaj Garg
Pankaj Garg

Reputation: 49

passing header in post method to access token

I am trying to pass header in post method for generating access token. however I am getting the wrror about invalid syntax. my header code is as below

headers=("Authorization: Basic RXadsdsdsdsdsdsdsdsdjkfhsuidhsuihf==","Content-Type: application/x-www-form-urlencoded")

headers=('Authorization': 'Basic RXadsdsdsdsdsdsdsdsdjkfhsuidhsuihf==','Content-Type': 'application/x-www-form-urlencoded')

Upvotes: 0

Views: 291

Answers (2)

nirmit
nirmit

Reputation: 55

You can try the below code:

auth_token = "Basic {}".format(token)
headers = {'Content-Type': 'application/json', 'Authorization': auth_token}

Upvotes: 1

Roomm
Roomm

Reputation: 925

Assuming that you are using Requests, headers should be a dictionary, so:

headers={
    "Authorization": "Basic RXadsdsdsdsdsdsdsdsdjkfhsuidhsuihf==",
    "Content-Type": "application/x-www-form-urlencoded"
}

Upvotes: 1

Related Questions