getOfflineOAuthToken method

Future<String?> getOfflineOAuthToken({
  1. ConnectorRef? connector,
  2. OAuthClientConfig? oauth,
  3. String? delegatedTo,
  4. String? delegatedBy,
})

Implementation

Future<String?> getOfflineOAuthToken({
  ConnectorRef? connector,
  OAuthClientConfig? oauth,
  String? delegatedTo,
  String? delegatedBy,
}) async {
  final req = <String, dynamic>{
    if (connector != null) 'connector': connector.toJson(),
    if (oauth != null) 'oauth': oauth.toJson(),
    if (delegatedBy != null) 'delegated_by': delegatedBy,
    if (delegatedTo != null) 'delegated_to': delegatedTo,
  };

  final res = await room.sendRequest('secrets.get_offline_oauth_token', req);

  if (res is JsonResponse) {
    final token = (res.json['access_token'] as String?) ?? '';
    if (token.isEmpty) {
      return null;
    }
    return token;
  } else {
    throw RoomServerException('Invalid response received, expected JsonResponse');
  }
}