> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.a1.uk.astutepayroll.in/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.a1.uk.astutepayroll.in/_mcp/server.

# OAuth Authorization

GET {{baseUrl}}/oauthv1/authorize

## OAuth Authorization

Initiates the **OAuth 2.0 Authorization Code flow** by redirecting the user to the authorization server. Upon successful authorization, the server redirects the user to the specified `redirectUri` with an authorization `code` that can be exchanged for an access token.

---

### Query Parameters

| Parameter | Required | Description |
| --- | --- | --- |
| `responseType` | ✅ Yes | Specifies the OAuth 2.0 response type. Must be set to `code` to initiate the Authorization Code flow. |
| `clientId` | ✅ Yes | The unique identifier of the registered client application (e.g., `client-id-123`). |
| `redirectUri` | ✅ Yes | The URI to which the authorization server will redirect the user after granting or denying access (e.g., `https://example.com/callback`). Must match the URI registered with the authorization server. |
| `scope` | ✅ Yes | A space-separated or comma-separated list of permissions being requested (e.g., `read write` or `read,write`). Defines the level of access the application is requesting. |
| `state` | ✅ Yes | An opaque value used to maintain state between the request and the callback (e.g., `state-123`). Helps prevent CSRF attacks by verifying the response matches the request. |

---

### Responses

**`200 OK`** **— Authorization code generated successfully**
The user has been successfully authorized. The response includes an authorization code that the client can exchange for an access token.

**`400 Bad Request`** **— Invalid input parameters**
The request was malformed or contained invalid/missing parameters. Check that all required query parameters are present and correctly formatted.

Reference: https://docs.a1.uk.astutepayroll.in/api-reference/authentication/o-auth-authorization

## Request

### Query parameters

- `responseType` (string, optional) — OAuth response type (typically "code")
- `clientId` (string, optional) — OAuth client ID
- `redirectUri` (string, optional) — Redirect URI for OAuth callback
- `scope` (string, optional) — OAuth scope
- `state` (string, optional) — State parameter for OAuth flow

## Examples

**SDK Code**

```python
import requests

url = "https://{{baseurl}}/oauthv1/authorize"

querystring = {"responseType":"{{code}}","clientId":"{{clientId}}","redirectUri":"{{redirectUri}}","scope":"{{scope}}","state":"{{state}}"}

response = requests.get(url, params=querystring)

print(response.json())
```

```javascript
const url = 'https://{{baseurl}}/oauthv1/authorize?responseType=%7B%7Bcode%7D%7D&clientId=%7B%7BclientId%7D%7D&redirectUri=%7B%7BredirectUri%7D%7D&scope=%7B%7Bscope%7D%7D&state=%7B%7Bstate%7D%7D';
const options = {method: 'GET'};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://{{baseurl}}/oauthv1/authorize?responseType=%7B%7Bcode%7D%7D&clientId=%7B%7BclientId%7D%7D&redirectUri=%7B%7BredirectUri%7D%7D&scope=%7B%7Bscope%7D%7D&state=%7B%7Bstate%7D%7D"

	req, _ := http.NewRequest("GET", url, nil)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://{{baseurl}}/oauthv1/authorize?responseType=%7B%7Bcode%7D%7D&clientId=%7B%7BclientId%7D%7D&redirectUri=%7B%7BredirectUri%7D%7D&scope=%7B%7Bscope%7D%7D&state=%7B%7Bstate%7D%7D")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://{{baseurl}}/oauthv1/authorize?responseType=%7B%7Bcode%7D%7D&clientId=%7B%7BclientId%7D%7D&redirectUri=%7B%7BredirectUri%7D%7D&scope=%7B%7Bscope%7D%7D&state=%7B%7Bstate%7D%7D")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://{{baseurl}}/oauthv1/authorize?responseType=%7B%7Bcode%7D%7D&clientId=%7B%7BclientId%7D%7D&redirectUri=%7B%7BredirectUri%7D%7D&scope=%7B%7Bscope%7D%7D&state=%7B%7Bstate%7D%7D');

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://{{baseurl}}/oauthv1/authorize?responseType=%7B%7Bcode%7D%7D&clientId=%7B%7BclientId%7D%7D&redirectUri=%7B%7BredirectUri%7D%7D&scope=%7B%7Bscope%7D%7D&state=%7B%7Bstate%7D%7D");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "https://{{baseurl}}/oauthv1/authorize?responseType=%7B%7Bcode%7D%7D&clientId=%7B%7BclientId%7D%7D&redirectUri=%7B%7BredirectUri%7D%7D&scope=%7B%7Bscope%7D%7D&state=%7B%7Bstate%7D%7D")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```