---
title: "Create OAuth2 authorization request"
method: POST
path: "/oauth/authorize"
tags: ["oauth-authorize"]
---

# Create OAuth2 authorization request

`POST /oauth/authorize`

## Request

- Base URL: `https://api.hoorayhr.io`
- URL: `https://api.hoorayhr.io/oauth/authorize`
- Auth: API key in header `authorization`

OAuth2 authorization request. If the user grants access, the response redirects back to your `redirect_uri` with an authorization code in the query string.

That code can then be exchanged for an access token via the `/oauth/token` endpoint, which provides access to the API.

**How to use**

Direct the user to the authorization URL in HoorayHR with the query parameters described below.

**Example**

`https://app.hoorayhr.io/oauth/authorize?response_type=code&client_id=1E2E2E8834912E3DCB5F267042E3EB74&redirect_uri=https:%2F%2Fintegration-partner.com&scope=profile_read%20profile_write&state=xcoivjuywkdkhvusuye3kch`

## Query parameters

- `response_type` string, required
- `redirect_uri` string, uri, required
- `client_id` string, required
- `scope` string, required
- `state` string

## Request body

- object
  - `allowAccess` boolean, required: boolean indicating if the user allows access.

## Response `200`

A successful request results in a redirect, leading the user back to the original application and adding an authorization code - in case the user granted access - the the query params. The code has a lifetime of 60 seconds and can be used just once. The code can be exchanged for an access token using the "oauth/token" endpoint.

- string, uri

---

[API](https://skmtc.dev/hoorayhr/apis/hoorayhr-api-documentation.md) · [All operations](https://skmtc.dev/hoorayhr/apis/hoorayhr-api-documentation/llms.txt) · [OpenAPI document](https://skmtc.dev/hoorayhr/apis/hoorayhr-api-documentation/revisions/3adcd47cd827?raw)
