Basic C2C Schema demo with AWS Lambda

Hi, this is my first post.

I’m trying to make a very basic ST C2C demo working with AWS Lambda. My goal is to add a device and pass some data, and work from there.

I have tried to do this using the sample Lambda function provided here:

I deployed it in eu-west-1.

I used the Glitch Oauth server. This works fine for me when used with a Webhook Endpoint.

After deploying the ST project, I am able to select its associated device from the ST App, but it does not attempt to open an authentication page and bombs back to the list of devices to add.

Nothing is appended to the glitch log so I presume it didn’t receive an OAuth request?

I am a total newbie and lack the experience to debug this, so I wondered if anyone could give me some pointers? Hopefully something simple / stupid? Since I can’t find any other posts describing a similar problem.

To clarify, my ST project is configured as:
Name: AWS Cloud Device
Client ID: dummy-client-id
Authorization URI: https://mock-oauth2-server.glitch.me/o/oauth2/v2/auth
Token URI: https://mock-oauth2-server.glitch.me/oauth2/v4/token
Hosting Type: AWS Lambda
ARN: arn:aws:lambda:eu-west-1:…:function:demoSTSchema (account ID removed)

I did also try the tutorial here but it has the added complication of zoom integration and custom device capabilities.

Hi!

This is strange indeed.

Did you use the same project to configure the Lambda Schema?
If so, please try with a new one, this is because:

  • If there was an issue with the Glitch OAuth server, you would receive a “network error” message when you clicked on the Schema project in the list.
  • If the issue were in the Lambda function, you would receive an error in the Developer Workspace due to the pre-check made when you register the function.

Once you create the new one, clear the app’s cache before installing the new one (this is to force a refresh of the App). For this, you need to go to your mobile device’s settings (Android only) > look for the Apps section > ST app > storage > clear cache

Just to confirm, please check the list I shared here of the thing we need to confirm when working with Lambda functions in ST Schema.

Hi Nayely,

Thanks os much for your help!

I implemented AWS Lambda on a separate project from the Webhook endpoint one.

I just tried removing all projects from test, just leaving the AWS Lambda one deployed. Then I deleted the smartthings app cache (IOS, so “offload app”) and reinstalled it.

I still get the same issue :thinking:

Going through your checklist:

  1. My Lambda function is deployed in eu-west-1, so I think that’s OK

  2. AWS CLI is configured for eu-west-1 and admin user (same as used to create lambda function)

  3. I ran the command to grant permission to Smartthings to access my Lambda function, using the ARN of the Lambda function, with this command and response: (confidential stuff redacted)
    % aws lambda add-permission --profile default --function-name demoSTSchema --statement-id smartthings --principal 148790070172 --action lambda:InvokeFunction
    {
    “Statement”: “{“Sid”:“smartthings”,“Effect”:“Allow”,“Principal”:{“AWS”:“arn:aws:iam::148790070172:root”},“Action”:“lambda:InvokeFunction”,“Resource”:“arn:aws:lambda:eu-west-1:[Account ID]:function:demoSTSchema”}”
    }

  4. The Lambda function has the node_modules folder / files, my lambda function filename is “index.js”, and runtime settings is set to “index.handler”.

Some screenshots:


Please let me know if there’s any further information I can add, or actions I could perform which might help diagnose the issue. Thanks!

Since everything seems to be OK, may be your default profile doesn’t have the same region as the lambda

Hi Erick! Thanks for your suggestion. I entered “aws configure get region” and got back “eu-west-1” which is as intended.

I later discovered that I would have received an error if trying to add permission with the wrong region, since no function exists there, and I also managed to confirm that permission is granted by looking at the Lambda console under “Permissions”:

More things I tried:
Corrupted the OAuth settings in the cloud connector settings → no change
Created a new lambda function in us-east-1, granted permission and connected to ST → no change
Renamed the index.js to index2.js and deployed → no change
Deleted node_modules folder and deployed → no change
there was never a sign that any lambda function has been invoked

So it seems the lambda function and Oauth server is not even contacted, indicating the issue is with SmartThings?

Can you help me check the following, please?

  • If the integration appears on Linked Services? In the SmartThings app, go to menu > settings > Linked Services
  • Did you clear the app’s cache as I mentioned above?
  • If you see the “my testing devices” option in the app, it is active there, but please, check if your device has the developer mode “on” as well.
  • Check if reinstalling the app helps (that is the last resource)

This is because I used the same OAuth configuration and I was able to install the device correctly in both regions eu-west-1 and us-east-1. Also, you mentioned it doesn’t even open the OAuth page without giving an error…

If this doesn’t solve the issue, I will report it to the engineering team.

Hi Nayely,

Yes, the integration does appear on the Linked Services menu. It is shown as disconnected, and when I try to sign in, I have the same behaviour as when trying to add device (starts to load a screen and immediately exits).

Yes, because I have an iOS device, I deleted the SmartThings app cache by removing it and reinstalling it. Note: I also installed the ST app on another device, logged in, enabled dev mode, and I had the same issue.

Developer mode is confirmed on.

Yes, I get no errors returned from this process.

Thanks again for your support!

Ok, I will need to check more details about this, to do so, I need your help by sharing the info below in a direct message:

  • The email account where you want to install the Schema Connector.
  • Schema Connector ID (It is the App ID shown in the Developer Workspace)