requestOAuthToken method
Future<String>
requestOAuthToken({
- required String fromParticipantId,
- required Uri redirectUri,
- required String delegateTo,
- ConnectorRef? connector,
- OAuthClientConfig? oauth,
- int timeout = 60 * 5,
Client -> server: Ask another participant (or the server) to obtain an OAuth token for us.
Returns the access_token string.
This matches the Python signature: request_oauth_token(authorization_endpoint, token_endpoint, scopes, timeout, from_participant_id)
Implementation
Future<String> requestOAuthToken({
required String fromParticipantId,
required Uri redirectUri,
required String delegateTo,
ConnectorRef? connector,
OAuthClientConfig? oauth,
int timeout = 60 * 5,
}) async {
final req = {
"connector": connector?.toJson(),
"oauth": oauth?.toJson(),
"redirect_uri": redirectUri.toString(),
"timeout": timeout,
"participant_id": fromParticipantId,
"delegate_to": delegateTo,
};
final res = await _invoke("request_oauth_token", req);
if (res is! JsonContent) {
throw _unexpectedResponseError("request_oauth_token");
}
final accessToken = (res.json["access_token"] as String?) ?? "";
if (accessToken.isEmpty) {
throw RoomServerException("Invalid response: missing access_token");
}
return accessToken;
}