I am trying to register a new OAuth client for a native mobile application integration using the SmartThings CLI. My goal is to create an API_ONLY app that uses a custom redirectUri for a mobile app authentication flow.
The Developer Workspace UI does not provide an option to set a Redirect URI for “Automation” projects, so I am using the CLI as per the documentation.
Problem: Every attempt to register the app via the CLI results in a 403 Forbidden error, even when using a Personal Access Token (PAT) that has every single available scope authorized.
AxiosError: Request failed with status code 403: {"requestId":"...","error":{"code":"ForbiddenError","message":"Access forbidden to this app.","details":[]}}
It seems that PATs are no longer being granted the necessary permissions to register apps via the CLI, despite the UI allowing all scopes to be selected.
Could you please advise on the correct, current procedure for registering an API_ONLY app with a custom redirect URI for a native mobile application?
I am a bit confused with what you are doing there. Your JSON payload looks like that required to create an app, not register it. Registering the app via the CLI just needs the appId of the created app on the command line.
The registration process for an app sends a CONFIRMATION request (the same process as for a Webhook SmartApp) to the targetUrl of your app after you have created it. The targetUrl is the one used for messages originating from the SmartThings end.
Then, you need to start the OAuth 2.0 process which consists on:
The Access Token you get expires in 24 hours.
The Refresh Token expires in 29 days if not used. We suggest you refresh the token before this time, otherwise, you’ll lose the Refresh token and the User will need to re-authorize.
NOTE: Remember the OAuth integration has alimit of 500 installations by default. Each time a user authorizes access to one of his/her locations, it will count as 1 installation. This means, if a user has 3 locations and authorizes access to each of them, he/she will use 3 installations.
To refresh the Access Token, you need to use the same endpoint but the grant_type is different, here’s an example about this: