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
Step One:
My Authorization Server receive a request from Smartthings App for the association:
Request:
Red Node receive the request with Client ID+Secret ID + State (generated from Smartthings platform)+ redirect URI
Response from Red Node:
location =msg.payload.redirect_uri+"?code=trucmachinchose&state="+msg.payload.state;
Statuscode=303
where:
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
Step Two:
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
jsonresponse={
“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.
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:
{
access_token: 'cestmontoken',
expires_in: '600',
refresh_token: 'cestmonrefreshtoken',
state:'value received from SmartThings in step one',
token_type: 'Bearer'
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.
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
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.
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?
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:
{
“headers”: {
“schema”: “st-schema”,
“version”: “1.0”,
“interactionType”: “refreshAccessTokens”,
“requestId”: “AE8E579B-0E3A-46F3-93FA-486DDE8B4E4B”
},
“globalError”: {
“errorEnum”: “INVALID-TOKEN”,
“detail”: “refresh token is malformed or call is made to wrong callback URL”
}
}
My request:
{
“schema”:“st-schema”,
“version”:“1.0”,
“interactionType”:“refreshAccessTokens”,
“requestId”:“AE8E579B-0E3A-46F3-93FA-486DDE8B4E4B”}
{
“grantType”:“refresh_token”,
“clientId”:“xxxxxxxx-b062-4455-b572-860976571cda”,
“clientSecret”:“xxxxxxxxx070b759aa84d16af86a450a39753128f98b08e442f4c2304424b8160d7436b1e8c4418ccab4c5d23cf56e9d2e5d767b5721bdaa11977a4c0a8b091d091aa7759298d212e98838e96e46e139bfed1b183158b56c677dd805022af344c19e3026b9f4de6993012c15437c025576fd79b0a043ed2c7adb88026857b5d76d6ae63092645b5483f3d33fabaffb11339b40463ced8da4cc2940cf6a09914c05c8735313c94e4c871fd8d9a00d7a47f1491d1d9e5e613aa948699aaab3c474829e9fdd679d4d3a8469a0aa3d8ad86a4ea225503a9166054b1bfad5982c7aee5d3ef542e1db54a1fd04ffe95a131c3c63e2a928dc64cce47e80d77355194ae3”,
“refresh_token”:“xxxxxxciOiJIUzM4NCJ9.MDljM2FiYTEtNWNiMS00MTUwLWE0NzgtM2RkYzQwMDk5MzgwOk15IENsb3VkIENvbm5lY3RvciBWMQ._WPg2tu-2g4Grjoz2TMh5AofMlgnf84L2KcuMPLibxw3QRTOc8S_mI9l-_ojgfTl”
}
I checked the Client ID, Secret ID and refresh Token (164 cars), i don’t see any errors.
Your request is correct, I refreshed my AccessToken just fine.
I need to look over this, so, please send an email to build@smartthings.com, and include this information: