Select to view content in your preferred language

How to generate token for RESTAPIs

76
1
Monday
UJJWALSINGH
New Contributor

I generated a token by following the process mentioned in the developer documentation, using dummy URLs to check the APIs in Postman. However, when I try to make a GET request, it shows an invalid token. Can someone please help me on this or identify where I made mistake ?

Tags (1)
0 Kudos
1 Reply
CodyPatterson
Regular Contributor

Hey @UJJWALSINGH 

I typically use this function here in Python to generate the token:

def GetToken(username, password):

    url = f'https://www.arcgis.com/sharing/generateToken?f=json&username={username}&password={password}&referer=http://www.arcgis.com'

    json = requests.get(url+'&f=json').json()

    return json['token']

Once the token is returned, this is how I enter it into Postman to use for testing purposes:

CodyPatterson_0-1720437350794.png

Postman will need to take the token as a Bearer Token, once that is input, everything should work fine!

If that doesn't end up working, let me know and I'll see what I can find!

Cody

0 Kudos