refreshRemoteToken static method

Future<Map<String, dynamic>?> refreshRemoteToken({
  1. required String clientId,
  2. required String clientSecret,
  3. required String oldRemoteToken,
})

This method fetches the token that grants temporary access to the bridge.

This is step 2. Step 1 is BridgeDiscoveryRepo.remoteAuthRequest.

clientId Identifies the client that is making the request. The value passed in this parameter must exactly match the value you receive from hue.

clientSecret The client secret you have received from Hue when registering for the Hue Remote API.

oldRemoteToken The old token that is being refreshed.

May throw ExpiredRefreshTokenException if the remote token is expired. If this happens, get the user to grand access to the app again by using BridgeDiscoveryRepo.remoteAuthRequest.

Implementation

static Future<Map<String, dynamic>?> refreshRemoteToken({
  required String clientId,
  required String clientSecret,
  required String oldRemoteToken,
}) async {
  // Call the service.
  Map<String, dynamic>? res = await TokenService.refreshRemoteToken(
    clientId: clientId,
    clientSecret: clientSecret,
    refreshToken: oldRemoteToken,
  );

  if (res == null) return null;

  return _formatRemoteTokenData(res);
}