How can users obtain a token to access the SmartThings API using the OAuth2 method?

  1. If we want to integrate smartthings API functionality, we need to be able user to log in to smartthings and get the corresponding token.
  2. Where can I find these related documents?
  3. I’ve only seen other people’s cases so far:Regarding API Access for Oauth integration

Operation Steps:

  1. Use the SmartThings CLI to create an app and obtain the clientId.
  2. Request through ‘https://api.smartthings.com/v1/oauth/authorize’, and upon logging in, I can obtain the corresponding code.
  3. When exchanging tokens with ‘https://api.smartthings.com/v1/oauth/token’ and the code, an error occurs: 404, keymanagement.service.invalid_request-authorization_code_invalid.

Hi, @haofei. Welcome to the SmartThings Community!

Do you mean when you login and authorize the access to your app you get the code, right?
As the error says “authorization_code_invalid”, I’m wondering if you’re using the right code in the request.

Note: Something important to note is that API access app have 500 max installs by default, if you will use more than that, you need to contact our Partners team to see if you can get a higher limit.
Each authorization from a user to each of his/her locations counts as 1 install.

2 Likes

After calling the ‘https://api.smartthings.com/v1/oauth/token’ interface to refresh the token, both the old “refresh_token” and “access_token” will become invalid, right?
If I don’t call the token refresh interface, the “refresh_token” is permanently valid, right?

Whether SmartThings’ OAuth 2.0 supports multi-point login?

Yes, they both get replaced.

No, the refresh token will expire in 30 days.

1 Like