handleOauthCallback Giving Error

Hello Team,
I have created the login into smartthing flow, earlier it was working fine but recently it started throwing the error in the following function of smartApp.

here ‘rt’ is

{ query: { code: 'Y1Jbj0' } }
 const outh = await smartApp.handleOAuthCallback(rt, context, callback);

Error:-

AxiosError: options must be an object
    at Object.assertOptions (/opt/nodejs/node_modules/@smartthings/core-sdk/node_modules/axios/lib/helpers/validator.js:62:11)
    at Axios.request (/opt/nodejs/node_modules/@smartthings/core-sdk/node_modules/axios/lib/core/Axios.js:65:15)
    at Function.wrap [as request] (/opt/nodejs/node_modules/@smartthings/core-sdk/node_modules/axios/lib/helpers/bind.js:5:15)
    at EndpointClient.<anonymous> (/opt/nodejs/node_modules/@smartthings/core-sdk/dist/endpoint-client.js:136:56)
    at Generator.next (<anonymous>)
    at fulfilled (/opt/nodejs/node_modules/@smartthings/core-sdk/dist/endpoint-client.js:5:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'ERR_BAD_OPTION_VALUE'
}

We havent change anything in the code, can you please help check it?

We have also tried by creating the new app but it still didnt work.

Hi, @Mohit_Gupta998
Welcome to the SmartThings Community!

I just tested the sample of API access in SmartThings’ Github and the handleOAuthCallback seems to be working fine. However, in that case, the call only sends the request as a parameter:

Also, the handler in the SmartApp SDK receives a single parameter:

So, I’m wondering if that could cause an issue, but do you remember when was the last time your current configuration worked?

Hello, It was working well a week ago.

Acc. to the code handleOAuthCallback just require a request parameter and it only use code from it so if I form a request object just with code, it should work?

req = { 'query':{'code':<code>}}

Update:-
I tried like this

const rt = { query: { code: 'Y1Jbj0' } }
 const outh = await smartApp.handleOAuthCallback(rt);

It still gives the same error.

we have created smartApp object like this

        const smartApp = new SmartApp()
            .appId( appId )
            .clientId( clientId )
            .clientSecret( clientSecret )
            .redirectUri( redirectUri );

Hi, @Mohit_Gupta998
I was able to replicate the issue with the latest versions of the modules included in package.json of the sample I mentioned above. The versions used there work correctly in case you want to install them temporarily to continue using your app. I reported this to the engineering team.

Hello,
Downgrading the version worked. Thanks

1 Like

Hi, @Mohit_Gupta998
Just to let you know that the engineering team released a new version of the SmartApp SDK to fix this issue, I tested again with this one and it seems to work correctly. Can you confirm, please?

1 Like