smartcar / node-sdk

Smartcar Node.js SDK
MIT License
49 stars 14 forks source link

Authentication Error using smart car connect Node JS sdk #120

Closed felixsieh closed 3 years ago

felixsieh commented 3 years ago

Hi there:

So I'm currently integrating with smartcar connect using the node js sdk and providing the clientId and secret to the config as follows:

  **_const client = new smartcar.AuthClient({
    clientId: 'xddjjfjfjfjjjfj0-dfjjfjfjfjf',
    clientSecret: 'c474998c-cf30-4779-b9dc-ddjdjdjdjddj',
    redirectUri: 'https://example.com/home',
    scope: ['read_odometer', 'read_vehicle_info', 'required:read_location']
  });_**

when I try to get a token by doing this: client.exchangeRefreshToken(tokenData.RefreshToken)

It's throwing this error _Unhandled rejection StatusCodeError: 401 - {"error":"authenticationerror","message":"Invalid authorization header. Format is Authorization: Bearer [token]"}

Is this because the client id and secret are not valid? I get the impression that it is requesting me to add the token to the header but I thought the client config above should build that under the hood. Can you please help?

Thanks,

gurpreetatwal commented 3 years ago

Hi @felixsieh :wave:

I think that error may be coming from a different call site. The client.exchangeRefreshToken method makes an HTTP request to our OAuth service and the error message you specified is only returned by our API service. The error message could be caused by an invalid "token" argument to the getVehicleIds or getUserId methods or the Vehicle constructor.

Hopefully that helps! :D

Feel free to e-mail support@smartcar.com if you need further help and our lovely support team will help you out