generateLogoutUrl method

Uri? generateLogoutUrl({
  1. Uri? redirectUri,
  2. String? state,
})

Returns an url to redirect to for a Relying Party to request that an OpenID Provider log out the End-User.

redirectUri is an url to which the Relying Party is requesting that the End-User's User Agent be redirected after a logout has been performed.

state is an opaque value used by the Relying Party to maintain state between the logout request and the callback to redirectUri.

See https://openid.net/specs/openid-connect-rpinitiated-1_0.html

Implementation

Uri? generateLogoutUrl({Uri? redirectUri, String? state}) {
  return client.issuer.metadata.endSessionEndpoint?.replace(queryParameters: {
    'id_token_hint': _token.idToken.toCompactSerialization(),
    if (redirectUri != null)
      'post_logout_redirect_uri': redirectUri.toString(),
    if (state != null) 'state': state
  });
}