Have new SmartApp - trying to control via REST API. Need help on obtaining auth code and token

Hello. New here.
I’ve owned Smartthings hub for about a year after moving over from Iris. I have a number of devices connected to the hub.
I am just now getting around to trying some custom automation.
I have a GE/Jasco Z-Wave Smart outlet that works fine through the app.
I have some surveillance cams plugged into this outlet. I have a monitor written that will email me when cam is on fritz so I can bounce the cam outlet via ST mobile app.

My objective is to capture email alert and trigger an automated power cycle of my z-wave smart outlet.

I have created a SmartApp and I can successfully powercycle the smart outlet there.
I’ve also been able to powercycle the outlet via curl command with the supplied temporary bearer token.

I need to automate the capture of the bearer token as i dont want to have to login manually each time to gather the latest bearer token.

I am using this guide here: https://docs.smartthings.com/en/latest/smartapp-web-services-developers-guide/authorization.html
It lists my first step is to obtain auth code. I built my GET like so:
https://graph.api.smartthings.com/oauth/authorize?scope=app&response_type=code&client_id=xxxxxclientIDxxxxxx&redirect_uri=http%3A%2F%2Flocalhost%3A4567%2Foauth%2Fcallback

The redirect URL was specified as an example to use when i setup my smartapp oauth settings.

When I run a GET on URL above, i get a full response including http formatting, content, etc.
When i drop my auth code request URL into chrome, i get taken to a page where i have to select my location (Home (15 devices) then i have to select the device, which my smart outlet is named “cams”.
Once i select these things, i then have to click a button named authorize. I then get redirected to my redir URL which contains the code i need in the URL. Obviously its a 404. URL=localhost:4567/oauth/callback?code=xxxxx

Is there a better way to do this? What should redir URL be?

It seems to me like maybe i need to specify the device more appropriately in my smartapp. When i run simulator on my smartapp, i also have to select location and device there too.

is there a better way to specify the device without having to select the device each time?

Maybe this will help with my auth code issue.
Thanks in advance.

You are looking at the old docs.

You can find the new API reference here

https://smartthings.developer.samsung.com/docs/api-ref/st-api.html

and info about tokens and authorization here

3 Likes

I will check out these resources and post back with my findings.
Thank you very much for your help!