API ReferenceOAuth 2.1 / OIDC
UserInfo Endpoint
Retrieve the authenticated user's profile claims using an OAuth access token.
Endpoint
GET /userinfoBase URL: https://api-id.avnology.net
Authentication: Bearer access token with openid scope
Returns the user's profile claims based on the scopes granted to the access token.
Request
curl https://api-id.avnology.net/userinfo \
-H "Authorization: Bearer eyJhbGciOiJSUzI1NiI..."Response
Success (200 OK)
{
"sub": "usr_4f18acec-2712-4be7-a9af-b063b4f6deba",
"email": "[email protected]",
"email_verified": true,
"name": "Jane Smith",
"given_name": "Jane",
"family_name": "Smith",
"preferred_username": "janesmith",
"picture": "https://cdn.id.avnology.net/avatars/usr_4f18acec.jpg",
Claims returned depend on the scopes:
| Scope | Claims |
|---|---|
openid | sub |
profile | name, given_name, family_name, preferred_username, picture, locale, zoneinfo, updated_at |
email | email, email_verified |
phone | phone_number, phone_number_verified |
Errors
| Status | Code | Description |
|---|---|---|
| 401 | AVNOLOGY_AUTH_205 | Access token expired |
| 401 | AVNOLOGY_AUTH_206 | Token revoked |
| 403 | AVNOLOGY_AUTH_101 | Missing openid scope |
Code Examples
JavaScript (fetch)
async function getUserInfo(accessToken) {
const response = await fetch('https://api-id.avnology.net/userinfo', {
headers: { 'Authorization': `Bearer ${accessToken}` },
});
return response.json();
}Python (httpx)
import httpx
def get_user_info(access_token: str) -> dict:
return httpx.get("https://api-id.avnology.net/userinfo",
headers={"Authorization": f"Bearer {Go (net/http)
func getUserInfo(ctx context.Context, accessToken string) (*UserInfoResponse, error) {
req, _ := http.NewRequestWithContext(ctx,
Related
- Token Endpoint -- obtain access tokens
- Discovery -- find the userinfo endpoint URL
- SDK:
client.oauth.getUserInfo()(TypeScript)