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

# SSO authentication callback

GET /v1/callback

Callback endpoint for OpenID Connect authentication flow.
The authorization server redirects here after successful authentication.

This endpoint receives the authorization code from the OpenID provider
and exchanges it for tokens. It then redirects the user to the application
callback URL that was specified in the initial authentication request.

The client application should not call this endpoint directly. It is
called automatically by the OpenID provider during the authentication flow.


Reference: https://ocient.ferndocs.com/api-reference/sso-integration/callback

## Request

### Query parameters

- `code` (string, required) — Authorization code received from the OpenID provider. This code will be exchanged for tokens.
- `state` (string, required) — State parameter used to prevent CSRF attacks. This value should match the state that was sent in the initial authentication request.

## Errors

### 401 Unauthorized Error

Unauthorized

- `status` (Status, required)

### 404 Not Found Error

Object not found

- `status` (Status, required)

## Types

### Status

- `reason` (string, required) — Human-readable description of the operation result
- `sql_state` (string, required) — SQL state code (see Error Handling section for common codes)
- `vendor_code` (integer, required) — Vendor-specific error code

## Examples

**SDK Code**

```python
import requests

url = "https://v1/callback"

querystring = {"code":"4/P7q7W91a-oMsCeLvIaQm6bTrgtp7","state":"fRJfv29f3v39Jf39dJf93jf"}

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

print(response.json())
```

```javascript
const url = 'https://v1/callback?code=4%2FP7q7W91a-oMsCeLvIaQm6bTrgtp7&state=fRJfv29f3v39Jf39dJf93jf';
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://v1/callback?code=4%2FP7q7W91a-oMsCeLvIaQm6bTrgtp7&state=fRJfv29f3v39Jf39dJf93jf"

	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://v1/callback?code=4%2FP7q7W91a-oMsCeLvIaQm6bTrgtp7&state=fRJfv29f3v39Jf39dJf93jf")

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://v1/callback?code=4%2FP7q7W91a-oMsCeLvIaQm6bTrgtp7&state=fRJfv29f3v39Jf39dJf93jf")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://v1/callback?code=4%2FP7q7W91a-oMsCeLvIaQm6bTrgtp7&state=fRJfv29f3v39Jf39dJf93jf');

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

```csharp
using RestSharp;

var client = new RestClient("https://v1/callback?code=4%2FP7q7W91a-oMsCeLvIaQm6bTrgtp7&state=fRJfv29f3v39Jf39dJf93jf");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "https://v1/callback?code=4%2FP7q7W91a-oMsCeLvIaQm6bTrgtp7&state=fRJfv29f3v39Jf39dJf93jf")! 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()
```