For clean Markdown of any page, append .md to the page URL. For a complete documentation index, see https://docs.ivfprovider.com/ivf-agency-ap-is/auth/llms.txt. For full documentation content, see https://docs.ivfprovider.com/ivf-agency-ap-is/auth/llms-full.txt.

# Generate Token

POST http://localhost:8000/api/auth/token
Content-Type: multipart/form-data

This is a GET request and it is used to "get" data from an endpoint. There is no request body for a GET request, but you can use query parameters to help specify the resource you want data on (e.g., in this request, we have `id=1`).

A successful GET response will have a `200 OK` status, and should include some kind of response body - for example, HTML web content or JSON data.

Reference: https://docs.ivfprovider.com/ivf-agency-ap-is/auth/generate-token

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: collection
  version: 1.0.0
paths:
  /api/auth/token:
    post:
      operationId: generate-token
      summary: Generate Token
      description: >-
        This is a GET request and it is used to "get" data from an endpoint.
        There is no request body for a GET request, but you can use query
        parameters to help specify the resource you want data on (e.g., in this
        request, we have `id=1`).


        A successful GET response will have a `200 OK` status, and should
        include some kind of response body - for example, HTML web content or
        JSON data.
      tags:
        - subpackage_auth
      parameters:
        - name: Authorization
          in: header
          description: Bearer authentication
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Auth_Generate Token_Response_200'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostApiAuthTokenRequestUnauthorizedError'
        '422':
          description: Unprocessable Content
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/PostApiAuthTokenRequestUnprocessableEntityError
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                client_id:
                  type: string
                client_secret:
                  type: string
                grant_type:
                  type: string
              required:
                - client_id
                - client_secret
                - grant_type
servers:
  - url: http://localhost:8000
components:
  schemas:
    Auth_Generate Token_Response_200:
      type: object
      properties:
        status:
          type: integer
        message:
          type: string
        access_token:
          type: string
        token_type:
          type: string
        expires_in:
          type: integer
      required:
        - status
        - message
        - access_token
        - token_type
        - expires_in
      title: Auth_Generate Token_Response_200
    PostApiAuthTokenRequestUnauthorizedError:
      type: object
      properties:
        status:
          type: integer
        message:
          type: string
      required:
        - status
        - message
      title: PostApiAuthTokenRequestUnauthorizedError
    ApiAuthTokenPostResponsesContentApplicationJsonSchemaErrors:
      type: object
      properties:
        client_secret:
          type: array
          items:
            type: string
        grant_type:
          type: array
          items:
            type: string
      required:
        - client_secret
        - grant_type
      title: ApiAuthTokenPostResponsesContentApplicationJsonSchemaErrors
    PostApiAuthTokenRequestUnprocessableEntityError:
      type: object
      properties:
        status:
          type: integer
        message:
          type: string
        errors:
          $ref: >-
            #/components/schemas/ApiAuthTokenPostResponsesContentApplicationJsonSchemaErrors
      required:
        - status
        - message
        - errors
      title: PostApiAuthTokenRequestUnprocessableEntityError
  securitySchemes:
    oauth2Auth:
      type: http
      scheme: bearer

```

## SDK Code Examples

```python Auth_Generate Token_example
import requests

url = "http://localhost:8000/api/auth/token"

payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"client_id\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"client_secret\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"grant_type\"\r\n\r\nstring\r\n-----011000010111000001101001--\r\n"
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "multipart/form-data; boundary=---011000010111000001101001"
}

response = requests.post(url, data=payload, headers=headers)

print(response.json())
```

```javascript Auth_Generate Token_example
const url = 'http://localhost:8000/api/auth/token';
const form = new FormData();
form.append('client_id', 'string');
form.append('client_secret', 'string');
form.append('grant_type', 'string');

const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

options.body = form;

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

```go Auth_Generate Token_example
package main

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

func main() {

	url := "http://localhost:8000/api/auth/token"

	payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"client_id\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"client_secret\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"grant_type\"\r\n\r\nstring\r\n-----011000010111000001101001--\r\n")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")

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

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

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

}
```

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

url = URI("http://localhost:8000/api/auth/token")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"client_id\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"client_secret\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"grant_type\"\r\n\r\nstring\r\n-----011000010111000001101001--\r\n"

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

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

HttpResponse<String> response = Unirest.post("http://localhost:8000/api/auth/token")
  .header("Authorization", "Bearer <token>")
  .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"client_id\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"client_secret\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"grant_type\"\r\n\r\nstring\r\n-----011000010111000001101001--\r\n")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'http://localhost:8000/api/auth/token', [
  'multipart' => [
    [
        'name' => 'client_id',
        'contents' => 'string'
    ],
    [
        'name' => 'client_secret',
        'contents' => 'string'
    ],
    [
        'name' => 'grant_type',
        'contents' => 'string'
    ]
  ]
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp Auth_Generate Token_example
using RestSharp;

var client = new RestClient("http://localhost:8000/api/auth/token");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddParameter("undefined", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"client_id\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"client_secret\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"grant_type\"\r\n\r\nstring\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Auth_Generate Token_example
import Foundation

let headers = ["Authorization": "Bearer <token>"]
let parameters = [
  [
    "name": "client_id",
    "value": "string"
  ],
  [
    "name": "client_secret",
    "value": "string"
  ],
  [
    "name": "grant_type",
    "value": "string"
  ]
]

let boundary = "---011000010111000001101001"

var body = ""
var error: NSError? = nil
for param in parameters {
  let paramName = param["name"]!
  body += "--\(boundary)\r\n"
  body += "Content-Disposition:form-data; name=\"\(paramName)\""
  if let filename = param["fileName"] {
    let contentType = param["content-type"]!
    let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
    if (error != nil) {
      print(error as Any)
    }
    body += "; filename=\"\(filename)\"\r\n"
    body += "Content-Type: \(contentType)\r\n\r\n"
    body += fileContent
  } else if let paramValue = param["value"] {
    body += "\r\n\r\n\(paramValue)"
  }
}

let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:8000/api/auth/token")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

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()
```