> For the complete documentation index, see [llms.txt](https://svgtas-organization.gitbook.io/php-oidc-client/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://svgtas-organization.gitbook.io/php-oidc-client/deal-with-the-provider/userinfo.md).

# UserInfo

The *userinfo\_endpoint* need the *access\_token*. If it's in session, you don't need to give it back.

The *id\_token* is required to verify the *sub* claim. If it's in session, you don't need to give it back.

The library support the response in *json* format and *jwt* (jwt signed by the OP with a key known in it's *jwks\_uri* endpoint or signed with the *client\_secret*).

```php
$client = new Svgta\OidcClient\init(
  'https://id.provider.com/.well-known/openid-configuration',
  'Your_client_id',
  'Your_client_secret'
);

// ...

$tokenRes = $client->token();
// ...
$tokens = $tokenRes->get_tokens();
// ...
$userInfo = $client->userInfo(); 
// method : $client->userInfo($access_token = null, $id_token = null);
// access_token and id_token are optionals if set in session (the method $tokenRes->get_tokens() do it)

```

> :warning: *userinfo\_endpoint* not set
>
> Some OP don't give an *userinfo\_endpoint* (Dropbox is an example). If the contents of the *id\_token* is enough for you, you can get the result of the *payload*
>
> ```php
> ...
> $tokenRes = $client->token();
> $tokens = $tokenRes->get_tokens();
> $payload = $tokenRes->get_id_token_payload(); //result is an array
> ```
>
> If you call *$client->userInfo()* but the OP don't have the *userinfo\_endpoint* set, you will get an *Svgta\OidcException*


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://svgtas-organization.gitbook.io/php-oidc-client/deal-with-the-provider/userinfo.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
