# How authentication works for REST APIs?

**URL:** <https://community-apimarket.att.com/t/how-authentication-works-for-rest-apis/289>\
**Category:** Security and authentication\
**Created:** [April 27, 2020, 2:57pm UTC](https://community-apimarket.att.com/t/how-authentication-works-for-rest-apis/289 "2020-04-27T14:57:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fatih\_Demirel](https://sea2.discourse-cdn.com/nyentek-att/user_avatar/community-apimarket.att.com/fatih_demirel/32/89_2.png) [@Fatih\_Demirel](https://community-apimarket.att.com/u/Fatih_Demirel)\
**Post date:** [April 27, 2020, 2:57pm UTC](https://community-apimarket.att.com/t/how-authentication-works-for-rest-apis/289/1 "2020-04-27T14:57:50Z")

</div>

In order to consume APIs on the AT&T API Marketplace (APIM) [https://apimarket.att.com](https://apimarket.att.com) you need to provide a valid `OpenID Connect 1.0 (OIDC)` _access token_ via all REST requests. It is expected within HTTP `Authorization` header as a bearer token.

There are two authentication flows supported:

- `OIDC password grant flow`
  - When there is a user to be authenticated, this is the supported flow.
  - As per spec, `grant_type` is _password_.
  - It requires _email address_ as `username`, APIM _password_ as `password` and _Account Client ID_ or _Public Project Key_ as `client_id`.

- `OIDC client credentials grant flow`
  - When being authenticating entity is a project, this flow should be used.
  - As per spec, `grant_type` is _client\_credentials_.
  - It requires _Private Project Key_ as `client_id` and _Private Project Secret_ as `secret`.

A successful authentication provides three OIDC tokens in `JSON Web Tokens (JWT)` format in `Base64` encoded _payload_ part:

- `access_token`: To be set into HTTP Authorization header of APIM REST APIs.
- `refresh_token`: To be provided to refresh the OIDC tokens without user credentials.
- `id_token`: To be used to fetch the `preferred_username` (your APIM userId (_projects also have APIM userId_) to be provided within REST API paths) and `call-did-list`/`sms-did-list` (telephone numbers assigned to this user/project).

> `access_token` is valid for _8 hours_, and `refresh_token` expires in _14 days_.

For more details about authentication flows and JWT examples, you can refer to [Authentication and Authorization](https://apimarket.att.com/developer/quickstarts/rest-api/get-started#get-started-authentication-and-authorization) on the AT&T API Marketplace Developer Documentation pages [https://apimarket.att.com/developer](https://apimarket.att.com/developer)
