Skip to content

Front-end Logout

Depending on the different terminals and specific usage scenarios, we provide two logout methods: front-end logout and back-end logout:

  • front-end logout: Front-end logout refers to the user accessing the logout address on the front-end. After logging out, the server will clear the user's login status. This logout method generally requires the participation of the browser and needs to be used in the browser environment. The Node SDK provides a method for generating a logout address, and developers can guide users to access this address on the front-end.

  • back-end logout: Back-end logout refers to calling the method of revoking access_token in the back-end service to invalidate the user's access_token and achieve the logout effect. It is suitable for scenarios where the login status is managed using Token.

This part of the document introduces the method of generating a front-end logout link.

Request parameters

NameTypeRequiredDefault valueDescriptionSample value
redirect_uristringNo-The callback address after logout. This address must be configured in the logout callback URL in the application configuration. When setting this parameter, idTokenHint must be passed at the same time.https://example.com/homepage
idTokenHintstringNo-The user's id_token. This parameter is required when postLogoutRedirectUri is set. id_token is used as the user's request credential to access this endpoint to prevent third parties from placing malicious logout addresses to induce users to click.xxxxxxxx
statestringNo-Custom intermediate state, which is any random string. When the user logs out and calls back to the callback address you configured, this state will be carried at the same time.some-random-string

Sample code

python
from authing import AuthenticationClient

# Initialize AuthenticationClient
authentication_client = AuthenticationClient(
# GenAuth application ID
app_id='GEN_AUTH_APP_ID',

# GenAuth application key
app_secret='GEN_AUTH_APP_SECRET',

# GenAuth application address, such as https://example.genauth.ai
app_host='GEN_AUTH_APP_HOST',

# Login callback address configured by GenAuth application
redirect_uri='GEN_AUTH_APP_REDIRECT_URI',
)

logout_url = authentication_client.build_logout_url(
redirect_uri="https://example.com/homepage",
# User's id_token can be obtained through the login interface
id_token="xxxxxxxx",
state="some-random-string"
)
print(url)

Request response

Type: string

Sample result:

txt
https://example.genauth.ai/oidc/session/end?post_logout_redirect_uri=xxx&id_token_hint=xxxx&state=xxxx

Agent infrastructure for identity, memory, and web action.