> 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*
