fetchRemoteToken static method
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.
pkce
The code verifier that was generated in
BridgeDiscoveryRepo.remoteAuthRequest. This is returned and captured
from the deep link.
code
The code that was returned from the deep link. This is what is
being traded for the token.
stateSecret
The state secret that was generated in
BridgeDiscoveryRepo.remoteAuthRequest. This method can either take the
full state value, or just the secret part.
Returns a map with the token, expiration date, refresh token, and token
type. If the token is not found, returns null
.
Implementation
static Future<Map<String, dynamic>?> fetchRemoteToken({
required String clientId,
required String clientSecret,
required String pkce,
required String code,
}) async {
// Call the service.
Map<String, dynamic>? res = await TokenService.fetchRemoteToken(
clientId: clientId,
clientSecret: clientSecret,
pkce: pkce,
code: code,
);
if (res == null) return null;
return _formatRemoteTokenData(res);
}