Call API from javascript

smartapp
api

(millionsun93) #1

Hi there.
I’m writing web app and i want to call api from javascript, so i have a problem with CORS, i searched community and found this thread


But JSONP request works by creating a script tag, therefore i cannot add custom headers (Authorization).
Can i call api from client side by javascript? or i must do it from server?
Thanks!


(Alex) #2

You can work around it by supplying access_token=abc-123 parameter in the JSONP request.

Note that token exposure is considered to be insecure and SmartThings really frowns upon any access token exposure.


(millionsun93) #3

thank you so much