0

I am connecting to LIVEStream API from Adobe and have tried using both Postman and a small Python code to connect. I am using the "Client Credentials" flow and I get the access token all right but the problem comes in when I pass that access token in the request header . I have followed the guide as mentioned in GitHub, so I do not understand what am I missing:

Postman Setup

enter image description here

I also have this sample python code to try the connection out and even there the same problem

from oauthlib.oauth2 import BackendApplicationClient
from requests_oauthlib import OAuth2Session
import requests

clientID="MyClientID"
clientSecret="MyClientSecret"

client = BackendApplicationClient(client_id=clientID)
oauth = OAuth2Session(client=client)
token = oauth.fetch_token(token_url='https://api.omniture.com/token', client_id=clientID,
        client_secret=clientSecret)
print(token)
accesstoken=(token['access_token'])

accesstoken=accesstoken.replace('\n', ' ').replace('\r', '')
print("after trim")

bearer_token = 'Bearer ' + accesstoken
header = {'Authorization': bearer_token}
header['Accept-Encoding']='gzip'
print(header)
url = 'https://livestream.adobe.net/api/1/stream/specificStream'
r = requests.get(url, headers=header)

response = requests.get(url,
                        headers = {'Authorization': 'Bearer {}'.format(accesstoken),'Accept-Encoding':'gzip'})

print(response.status_code)
print(response.content)

The output is the same: 401 b'invalid authorization header\r\n'

I have followed the guide in https://github.com/AdobeDocs/analytics-1.4-apis/blob/master/docs/live-stream-api/data_requests.md

So, not sure what's missing. Has anyone seen this before? As mentioned before, I get a token alright and it's only while trying to fetch the stream do I get a invalid authorization header.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Saugat Mukherjee
  • 778
  • 8
  • 32

1 Answers1

0

Ok, I have found the problem. Actually upon using Fiddler and CURL with a -v option I found that there was a 302 redirect and the authorization headers are stripped off during that redirect. When I pointed my URL to the 302 redirect URI, I could get the data. I will now try and handle this in my code. Hopefully someone will find this useful.

Saugat Mukherjee
  • 778
  • 8
  • 32
  • Hi Saugat! Do you remember if you resolved the problem in the sample of Python code posted? I would like to start using LiveStream API with Python but can't find any samples of code on this topic. – PyRar Jul 01 '19 at 20:16
  • @PyRar Yes, I was able to. I was struggling with it and then even posted a question on it , and finally the answer too myself :). You can find the details here : https://stackoverflow.com/questions/53556273/read-http-stream – Saugat Mukherjee Jul 01 '19 at 20:38