requestOpenIdToken method
Gets an OpenID token object that the requester may supply to another service to verify their identity in SDN. The generated token is only valid for exchanging for user information from the federation API for OpenID.
The access token generated is only valid for the OpenID API. It cannot
be used to request another OpenID access token or call /sync
, for
example.
userId
The user to request an OpenID token for. Should be the user who
is authenticated for the request.
body
An empty object. Reserved for future expansion.
Implementation
Future<OpenIdCredentials> requestOpenIdToken(
String userId, Map<String, Object?> body) async {
final requestUri = Uri(
path:
'_api/client/v3/user/${Uri.encodeComponent(userId)}/openid/request_token');
final request = Request('POST', baseUri!.resolveUri(requestUri));
request.headers['authorization'] = 'Bearer ${bearerToken!}';
request.headers['content-type'] = 'application/json';
request.bodyBytes = utf8.encode(jsonEncode(body));
final response = await httpClient.send(request);
final responseBody = await response.stream.toBytes();
if (response.statusCode != 200) unexpectedResponse(response, responseBody);
final responseString = utf8.decode(responseBody);
final json = jsonDecode(responseString);
return OpenIdCredentials.fromJson(json as Map<String, Object?>);
}