user3330601 user3330601 - 2 months ago 5x
Python Question

Unclear on making an API call after authentication?

I am looking on how to use an APIs, more specifically Egnyte's API.

From their documentation, I must first get a oauth2 token, which I was able to get successfully.

Here are their documentation:

However, I am not sure what to do afterwards. I am trying to use their User management API, which I am suppose to make a call to:

https://{Egnyte Domain}

However, how do i use their token for a requests.get call to their api?
Below is my python code, I am using the the Requests Module (

import requests

api_key = 'MY_API_KEY'
username = 'myUserName'
password = 'myPassword'

payload = {
'grant_type': 'password',
'client_id': api_key,
'username': username,
'password': password

token ="https://{Egnyte Domain}", params = payload)

print r.text

The response I get is:




Ah, someone had showed me.

had to do minor adjustments to the script:

r ="https://{Egnyte Domain}", params=payload)
token = r.json()['access_token']

users = requests.get(url, headers={'Authorization': 'Bearer %s' % token})