How to pass access token to API call using python?


#1

Hi

how can i pass the access token when calling intercom API using python?

import requests
url=“https://api.intercom.io/users?user_id=abcd
r = requests.get(url) #how to send the access token with the url ?

Thanks


#2

Hey @ammar.khwaira - Python is not an officially supported SDK yet, so from an Intercom point-of-view, it’s difficult for me to say.

However, as a member of the community, I can say that the below should work with the requests package :wink: More here!

import requests

url = 'https://api.intercom.io/users?user_id=abcd'
headers = {'Authorization' : 'Bearer <Your access token>'}

r = requests.get(url, headers=headers)

Alternatively, you can install this third-party wrapper and use the below. Just bear in mind that it’s not officially supported.

from intercom.client import Client
intercom = Client(personal_access_token='my_personal_access_token')