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 = {
if (connector != null) "connector": connector.toJson(),
if (oauth != null) "oauth": oauth.toJson(),
"redirect_uri": redirectUri.toString(),
"timeout": timeout,
"participant_id": fromParticipantId,
"delegate_to": delegateTo,
};
final res = await room.sendRequest("secrets.request_oauth_token", req) as JsonResponse;
final accessToken = (res.json["access_token"] as String?) ?? "";
if (accessToken.isEmpty) {
throw RoomServerException("Invalid response: missing access_token");
}
return accessToken;
}