Skip to content
Stand with Ukraine flag

Configure OAuth 2.0 in ThingsBoard Mobile Application

The mobile app supports OAuth 2.0 authentication. When configured, additional sign-in buttons appear on the login screen so users can authenticate with the configured OAuth 2.0 provider. A System Administrator configures OAuth 2.0. For general OAuth configuration, see OAuth 2.0 Support.

  1. As a System Administrator, go to System SettingsOAuth2.
  2. Expand the domains panel.
  3. Open the Mobile applications tab and click Add application.
  4. Enter your application package name — for Android: the Application ID; for iOS: the Product Bundle Identifier.
  5. Copy the auto-generated Application secret, or enter your own.
  6. Click Save in the bottom-right corner to apply the changes.

Open the `flutter_thingsboard_pe_app` project in your editor. Edit lib/constants/app_constants.dart:

  • Set thingsboardOAuth2AppSecret to the Application secret value from the previous step.
  • Set thingsboardOAuth2CallbackUrlScheme to a unique scheme — for example, your application package name with an auth suffix (like org.mycompany.myapp.auth).
abstract class ThingsboardAppConstants {
// ...
static final thingsboardOAuth2CallbackUrlScheme = 'Your callback url scheme here';
static final thingsboardOAuth2AppSecret = 'Your app secret here';
}

Next, edit android/app/src/main/AndroidManifest.xml. Find TbWebCallbackActivity and set its scheme to the same value as thingsboardOAuth2CallbackUrlScheme:

<activity android:name=".TbWebCallbackActivity">
<intent-filter android:label="tb_web_auth">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="Your callback url scheme here" />
</intent-filter>
</activity>

Run the mobile app. The login screen should show the OAuth 2.0 sign-in button(s) at the top. Use one to log in as an existing user to confirm the setup works.