fetchAccessToken static method
Calls the sandbox token endpoint with the client_credentials grant.
Implementation
static Future<String> fetchAccessToken({
required String clientId,
required String clientSecret,
}) async {
final response = await _dio.post<Map<String, dynamic>>(
'https://sandbox-auth.swichnow.com/connect/token',
data: {
'grant_type': 'client_credentials',
'client_id': clientId,
'client_secret': clientSecret,
},
options: Options(contentType: Headers.formUrlEncodedContentType),
);
return response.data!['access_token'] as String;
}