Hi, I am implementing the oauth2 part of my smartapp and the authorize step directs to error=invalid_request&error_description=The+request+is+malformed.
Hi, @rst11
This is weird. You should be redirected to the “redirect URI” you defined in your app’s configuration, along with the authorization code as the query parameter. Have you checked if you receive that request on your server?
I haven’t seen this flow redirecting to the installedapp endpoint.
Hi @nayelyz . does this mean the &redirect_url= specified on the url the client is being directed to is completely ignored? can i remove it so not to cause confusion.
Are there any logs that i can view that will explain why the there is no call to the url specified on the application registration?
can you explain what you mean by: >> I haven’t seen this flow redirecting to the installedapp endpoint.
No, it is used, but it must match the redirect URI you defined in your app’s configuration. Both must be present.
Not directly, but you can test first if your URL passes this SSL test: SSL Server Test (Powered by Qualys SSL Labs)
If not, that could be the reason why no request reaches your server.
Something I have observed is that using the CLI command smartthings apps:oauth:generate (at least I think it was that one) results in a spurious https://apps.smartthings.com/installedapp/ being added as the first entry in the redirectUris array. There is still no obvious reason why it should be used instead of the specified one but I’ve had it happen.
I do not use this command. I create the app via Postman and I’ve defined my REDIRECT_URI in the body. If the URI were incorrect, I would receive an error in the response body stating that the REDIRECT_URI is invalid
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:
Hey, I tried that, but I need WEBHOOK_SMART_APP to receive calls from SmartThings when a device changes its state. When I use the API_ONLY type, I can’t use the webhook functionality. i need a way to use the api to controll my device state and to get his state from the webhook
API_ONLY apps receive CONFIRMATION and EVENT messages from SmartThings on the ‘target URL’ just as WEBHOOK_SMART_APP apps do. The difference is that instead of a lifecycle property in a request from SmartThings you get a messageType.
As you are basically setting things up from the server end rather than responding to requests from SmartThings, you don’t get CONFIGURATION, INSTALL, or UPDATE lifecycle requests. However you can still create subscriptions as you would typically have done in response to those INSTALL or UPDATE requests and you will receive EVENT messages.
Hey Orangebucket, thank you so much for your answer i tried to subscribe for my device, but SmartThings didn’t trigger or call my webhook, my webhook is also currect “apiOnly”: {
“targetUrl”: “https://api.screen-board.com/api/auth/smartthings/webhook”
I believe I’ve done everything correctly, but Samsung/SmartThings never calls the webhook. I tested by turning off the light via Alexa, but nothing happens—even though I have an active subscription.
I believe that’s how it looks in the input when creating or updating apps from JSON, but it should end up looking like this is the app object when it is ready to go:
You need to use smartthings apps:register (or an API equivalent) to trigger the CONFIRMATION cycle to verify your target URL (though I believe it also gets called if you define the target URL when you first create an app). That’s the same deal as with Webhook SmartApps.