Get report data from API

I can make a call to /api/xxx with no problem and it gets a JSON result. This implies my token auth is working.

I'm getting 401 access errors, and my URI looks like:

https://modeanalytics.com/api/xxx/reports/128c58442c33

Python code below.

------

from urllib2 import Request, urlopen

 

token = "xxxx"

password = "yyyy"

 

headers = {

  'Content-Type': 'application/json',

  'Accept': 'application/hal+json',

  'Authorization': "access_token %s" % (token)

}

 

# report

# https://modeanalytics.com/xxx/reports/abcabcabc

 

url = 'https://modeanalytics.com/api/xxx/reports/128c58442c33'

 

print headers

print url

 

request = Request(url, headers=headers)

 

response_body = urlopen(request).read()

print response_body

2replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • Hi Ryan Choi , The "Authentication" value would need to be access token/access secret (you should get both of these upon generating an access token) base 64 encoded. You can write a small Python/Ruby script to generate that value. The word "access_token" doesn't need to be included in the value. Let me know if that helps! 

    Reply Like
  • Leqi Long Can you be more specific?  Typically HTTP Basic auth header looks something like {'Authorization': 'Basic adf98ss98d9s8=='}, where the Base64 encoded string is in the format of user:password.  I believe that what you are saying here is that the encoded string should be "token/secret", but I haven't had success with that.

    Reply Like
Like2 Follow
  • Status Answered
  • 2 Likes
  • 7 days agoLast active
  • 2Replies
  • 1287Views
  • 4 Following

Create A New Discussion

Share your thoughts