SDKsGo SDKAuthentication
Session Management
Get, list, and revoke user sessions with the Go SDK.
Session Management
GetSession()
Validate and retrieve a session.
session, err := client.Auth.GetSession(ctx, &avnologyid.GetSessionParams{
SessionToken: "token_from_header",
})
if err != nil {
// Not authenticated
return
}
fmt.Println(session.ID)
fmt.Println(session.Identity.Email)
fmt.Println(session.AuthenticatorAssuranceLevel) // "aal1" or "aal2"
fmt.Println(session.Active)
fmt.Println(session.ExpiresAt)ListSessions()
result, err := client.Auth.ListSessions(ctx, &avnologyid.ListSessionsParams{
PageSize: 25,
})
if err != nil {
log.Fatal(err)
}
for _, session := range result.Sessions {
fmt.Printf("Session %s: %s from %s\n",
session.ID,
session.Devices[0].UserAgent,
session.Devices[0].IPAddress,
)
}RevokeSession()
err := client.Auth.RevokeSession(ctx, &avnologyid.RevokeSessionParams{
SessionID: "ses_abc123",
})RevokeAllSessions()
err := client.Auth.RevokeAllSessions(ctx)See also
- Login -- Authentication
- Session types -- Go struct definitions