0

Why is it that I receive a 401 Error when I attempt to get info from the HOST here?

I'm using my token, shouldn't that give me full access?

   HOST = "https://api.surveymonkey.com/v3/surveys"


   r= requests.get(HOST, api_token)
   r.text
   print r
jeepers mcface
  • 371
  • 1
  • 5
  • 15

2 Answers2

2

You pass api_token in a wrong way. Read the website document to see how do they pass token is the right way to solve your question.

In ordinary situations we will do something like this:

requests.get(HOST, auth=(user,api_token))

But sometime we can pass token into headers straightly:

requests.get(HOST, headers={'Authorization': "Bearer {}".format(api_token)})
requests.get(HOST, headers={'Authorization': api_token})

Read Python requests library how to pass Authorization header with single token to know more about how to pass token straightly.

KC.
  • 2,981
  • 2
  • 12
  • 22
0

https://developer.surveymonkey.com/api/v3/?python#surveys

Python example is on the right.

Adam Klockars
  • 301
  • 1
  • 3