Simple Smart Cloud Connector with Red Node


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:

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;
msg.payload.redirect_uri is the smartthing 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
“access_token” : “cestmontoken”,
“token_type” : “Bearer”,
“expires_in” : “600”,
“refresh_token” : “cestmonrefreshtoken”,
“redirect_uri” : “

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?

Tagging @nayelyz.

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.

1 Like

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)

Hello @Ej3359,

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 : ''

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.

Hello nayelyz

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

and after, with the token, i can use the with token to send the update of my device?


Hi @Ej3359,

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.


Hello @nayelyz,

Thanks, that’s work fined! :slight_smile:

1 Like

Hello @nayelyz,

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:

  1. Click on menu > settings.
  2. Find the option “Linked services” and enter.
  3. Then click on the button located in the top-right corner and select “Delete”.
  4. Choose the name of your Cloud connector and confirm.

This will also delete all the devices discovered using this connector.

Hello @nayelyz,

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, 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:
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, 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:

    "headers": {
        "schema": "st-schema",
        "version": "1.0",
        "interactionType": "refreshAccessTokens",
        "requestId": "abc-123-456"
    "callbackAuthentication": {
        "grantType": "refresh_token",
        "clientId": "xxxxxx",
        "clientSecret": "xxxxxx",
        "refreshToken": "xxxxx"

You don’t have to wait and the same refreshToken is valid until you delete the connector.

Thank’s, It’s ok