Basic cURL for /devices

Hi all,

Trying to get the API to work for use with a SmartThings Button (IM6001-BTP01) and I’m getting a 401. I’m using curl here:

$ curl https://auth-global.api.smartthings.com/devices -X GET -H 'authorization: access_token <access_token>'
{"timestamp":1599436493402,"status":401,"error":"Unauthorized","message":"Unauthorized","path":"/devices"} 

I get the same error with Python:

import requests
requests.get("https://auth-global.api.smartthings.com/devices", headers={'Authorization': 'access_token <access_token>'})
<Response [401]>

I have deleted and regenerated this access token, and I get the same error.

These are the permissions on the token:

r:locations:*, w:customcapability, x:rules:*, l:installedapps, r:scenes:*, r:customcapability, w:rules:*,
 w:schedules, x:notifications:*, w:installedapps:*, x:scenes:*, r:installedapps:*, r:schedules,
 w:deviceprofiles, r:rules:*, x:devices:*, l:devices, w:locations:*, r:devices:*, w:devices:*, x:locations:*,
 r:apps:*, r:deviceprofiles, w:apps:*

I figured it out by looking at somebody else’s post. The correct format for a curl is this:

curl -X GET 'https://api.smartthings.com/v1/devices/' -H 'Authorization: Bearer <api_token>'
2 Likes