# Retrieve information about the current caller

`GET /api/2/whoami`

Get information about the current caller, e.g. the auth subjects that are generated for the caller.

Authentication (security requirement alternatives):

```json
[
  {
    "OpenIDConnect": []
  },
  {
    "NginxBasic": []
  },
  {
    "Bearer": []
  }
]
```

- OpenIDConnect: openIdConnect. OpenID Connect Discovery URL. The placeholder is replaced by Swagger UI when configured.
- NginxBasic: http (basic). Eclipse Ditto sandbox demo user (demo1 ... demo9) + password (demo)
- Bearer: http (bearer). A JSON Web Token issued by a supported OAuth 2.0 Identity Provider.

Responses:

- 200: The request successfully returned information about the caller.

Content type: application/json

Type: WhoAmI

Contains information about the current user and the auth subjects available for the used authentication.

Schema: [WhoAmI](https://sourcey-ditto.pages.dev/http-api-doc/models/whoami.md)

- `defaultSubject` (optional)
  Reference: [WhoAmISubject](https://sourcey-ditto.pages.dev/http-api-doc/models/whoamisubject.md); Type: WhoAmISubject
  
  An auth subject that can be used to provide access for a caller (e.g. in subject entries of policies).

- `subjects` (optional)
  Type: Array<WhoAmISubject>
  
  Items:
    Reference: [WhoAmISubject](https://sourcey-ditto.pages.dev/http-api-doc/models/whoamisubject.md); Type: WhoAmISubject
    
    An auth subject that can be used to provide access for a caller (e.g. in subject entries of policies).

- 401: The request could not be completed due to missing authentication.

Content type: application/json

Type: AdvancedError

Schema: [AdvancedError](https://sourcey-ditto.pages.dev/http-api-doc/models/advancederror.md)

- `status` (required)
  Type: integer
  
  The HTTP status of the error

- `error` (required)
  Type: string
  
  The error code of the occurred exception

- `message` (required)
  Type: string
  
  The message of the error - what went wrong

- `description` (optional)
  Type: string
  
  A description how to fix the error or more details

- `href` (optional)
  Type: string
  
  A link to further information about the error and how to fix it

## Examples

### cURL

```bash
curl -X GET 'https://ditto.eclipseprojects.io/api/2/whoami' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

### JavaScript

```javascript
const response = await fetch('https://ditto.eclipseprojects.io/api/2/whoami', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.get(
    'https://ditto.eclipseprojects.io/api/2/whoami',
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
    },
)
print(response.text)
```
