Identifying user in backend
its considered ok to write the session id and sessionToken of user in a cookie and identify the user calling {zitadelApi}/v2/sessions/{sessionId}?sessionToken={tokenId}
?
?
sessionId and sessionToken in a cookie to identify users is a valid approach when building a custom login UI with the Session API. (1) client_id and client_secret as a Basic Auth headerclient_id. For client_secret_post authentication, you should send both client_id and client_secret as parameters in the body: (1) Basic base64(client_id:client_secret) . ${BASIC_AUTH} is the base64-encoded string of client_id:client_secret. If the Basic Auth header isn't being parsed correctly, ZITADEL will fall back to requiring client_id in the body.code in --data code=${code} is the authorization code that was issued from the authorization request. (1) redirect_uri (callback endpoint)code parameter in the URLcode and use it in the token request (2) code and if provided the unmodified state parameter. You will need this code in the token request." V2_224908753244265546 is the authRequestId — the unique identifier of the authorization request. (1) (2) /oauth/v2/authorize) , ZITADEL creates an auth request and redirects to your login UI with this ID in the URL. You extract it from that redirect URL. authRequestId identifies the specific OIDC flow in progress. You use it to:clientId, scope, redirectUri, etc.:V2_ prefix indicates it's from the v2 API. (3) sessionTokenrefresh_tokenclient_idclient_idclient_idclient_idclient_secretclient_secretBasic base64(client_id:client_secret) ${BASIC_AUTH}client_id:client_secret--data code=${code}redirect_uriV2_224908753244265546/oauth/v2/authorizeauthRequestIdscoperedirectUriV2_curl --request POST \
--url ${CUSTOM_DOMAIN}/v2/oidc/auth_requests/V2_224908753244265546 \
--header 'Accept: application/json' \
--header 'Authorization: Bearer '"$TOKEN"''\
--header 'Content-Type: application/json' \
--data '{
"session": {
"sessionId": "225307381909694508",
"sessionToken": "7N5kQCvC4jIf2OuBjwfyWSX2FUKbQqg4iG3uWT-TBngMhlS9miGUwpyUaN0HJ8OcbSzk4QHZy_Bvvv"
}
}'curl --request POST \
--url ${CUSTOM_DOMAIN}/oauth/v2/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data grant_type=authorization_code \
--data code=${code} \
--data redirect_uri=${redirect_uri} \
--data client_id=${client_id} \
--data code_verifier=${code_verifier}curl --request POST \
--url ${CUSTOM_DOMAIN}/oauth/v2/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic ${BASIC_AUTH}' \
--data grant_type=authorization_code \
--data code=${code} \
--data redirect_uri=${redirect_uri}curl --request POST \
--url ${CUSTOM_DOMAIN}/oauth/v2/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic ${BASIC_AUTH}' \
--data grant_type=authorization_code \
--data code=${code} \
--data redirect_uri=${redirect_uri}curl --request POST \
--url ${CUSTOM_DOMAIN}/oauth/v2/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data grant_type=authorization_code \
--data code=${code} \
--data redirect_uri=${redirect_uri} \
--data client_id=${CLIENT_ID} \
--data client_secret=${CLIENT_SECRET}curl --request GET \
--url <https://$%7BCUSTOM_DOMAIN%7D/v2/oidc/auth_requests/V2_224908753244265546> \
--header 'Authorization: Bearer '"$TOKEN"''