I would like create a simple Smart Cloud Connector to connect a Red Node Device (on a RPI)
The purpose is to interface my Texecom Alarm with Smartthings
I have some incomprehension with the smartthings callback (I’m newbie with OAuth)
My Authorization Server is on Red Node
My Authorization Server receive a request from Smartthings App for the association:
Red Node receive the request with Client ID+Secret ID + State (generated from Smartthings platform)+ redirect URI
Response from Red Node:
msg.payload.redirect_uri is the smartthing callback: https://c2c-eu.smartthings.com/oauth/callback
code is the code generated from Red Node
State is the sate from the Smartthings Request
Step One is ok, i think
Red Node receive a Token Request from Smarthings
Request From Smartthings to Red Node:
Request (Post) with Grant_Type, Code, Redirect_uri
Response From Red Node to Smartthings
Return a json with token, refresh token and expires
“access_token” : “cestmontoken”,
“token_type” : “Bearer”,
“expires_in” : “600”,
“refresh_token” : “cestmonrefreshtoken”,
“redirect_uri” : “https://c2c-eu.smartthings.com/oauth/callback”
After that, the Smartthings App accept the association but with an error on the callbak function
I think i need to specify some parameter in the redirect-uri.
May you help me?
Sorry, i don’t understand.
Why do you specify Tagging?
@nayelyz is a SmartThings partner who has a better understanding of the new API, than most of us.
Otherwise you can look at this NodeRED project for inspiration:
This uses a SmartApp to connect your local NodeRed to the SmartThings hub.
Thanks but i would simulate a device and not pilot the smartthing’s devices
For the moment, i can link to smartthings cloud connector but with an error on the callback.
Si i received discover et state request but i can not make a callback interactiob (i think)
Can you share with me the complete log of the callback error, please?
From your description, I can see that you are missing the
state parameter in your response to SmartThings. It should be similar to the example below:
state:'value received from SmartThings in step one',
redirect_uri : 'https://c2c-eu.smartthings.com/oauth/callback'
Make sure that after the grantAccessCallback, you request an Access Token to SmartThings using the code located in the callbackAuthentication, the Client ID and Client Secret (obtained in the developer Workspace). You will need that token to send stateCallbacks from your cloud.
Thanks for your help. Now, i’ll received a grant access (Post Method on the my URL’s connector)
What is the next step to obtain the token:
1°) a response with status 200 on the Grant Callback Access.
2°) Make an Http post to https://c2c-eu.smartthings.com/oauth/token
and after, with the token, i can use the https://c2c-eu.smartthings.com/device/events with token to send the update of my device?
You’re right. For number 2, make sure to follow the guidelines to obtain the Reciprocal Token.
The updates are sent to the stateCallback URL using the structure shown for the Device State Callback interaction.
Thanks, that’s work fined!
Do you know the way to Delete the service (my connector) in the Smartthings App?
I have delete my project in the Developer Workspace but i received request from Smartthings Cloud?
Sure! In the SmartThings app:
- Click on menu > settings.
- Find the option “Linked services” and enter.
- Then click on the button located in the top-right corner and select “Delete”.
- Choose the name of your Cloud connector and confirm.
This will also delete all the devices discovered using this connector.
Thanks, I’m on IOS but that works with Android APP. I added the integrationDelete function on Red Node , it solde the problem
I can get the token and refresh the token to callback ST, but I’m having trouble renewing the refresh token.
When i make a request to https://c2c-eu.smartthings.com/oauth/token, i have this response:
“detail”: “refresh token is malformed or call is made to wrong callback URL”
I checked the Client ID, Secret ID and refresh Token (164 cars), i don’t see any errors.
May you help me?
Your request is correct, I refreshed my AccessToken just fine.
I need to look over this, so, please send an email to firstname.lastname@example.org, and include this information:
- Complete logs of the request
- App ID of the schema connector (e.g. viper_xxxx)
- Last DateTime when you made the request
I have send an email.
I have a question: Should I wait until the access token has expired before renewing the refresh token? or i can make before the expiration?
thanks! Now I see what happened, you wrote
refresh_token instead of
refreshToken. If you change that, the request will be ok.
Check this sample:
You don’t have to wait and the same refreshToken is valid until you delete the connector.