## Authorize user app with and without PKCE

### cURL

```
curl --request GET \
  --url https://yourcompany.login.fabric.inc/oauth2/default/v1/authorize
```

### Python

```
import requests

url = "https://yourcompany.login.fabric.inc/oauth2/default/v1/authorize"

response = requests.get(url)

print(response.text)
```

### JavaScript

```
const options = {method: 'GET'};

fetch('https://yourcompany.login.fabric.inc/oauth2/default/v1/authorize', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### PHP

```
<?php

$curl = curl_init();

curl_setopt_array($curl, [\
  CURLOPT_URL => "https://yourcompany.login.fabric.inc/oauth2/default/v1/authorize",\
  CURLOPT_RETURNTRANSFER => true,\
  CURLOPT_ENCODING => "",\
  CURLOPT_MAXREDIRS => 10,\
  CURLOPT_TIMEOUT => 30,\
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\
  CURLOPT_CUSTOMREQUEST => "GET",\
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
?>
```

### Go

```
package main

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

func main() {

url := "https://yourcompany.login.fabric.inc/oauth2/default/v1/authorize"

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

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

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

fmt.Println(string(body))
}
```

### Unirest (Java)

```
HttpResponse<String> response = Unirest.get("https://yourcompany.login.fabric.inc/oauth2/default/v1/authorize")
  .asString();
```

### Ruby

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

url = URI("https://yourcompany.login.fabric.inc/oauth2/default/v1/authorize")

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

### Query Parameters

- **client_id**  
  *string*  
  Required. Client ID of the user app.

- **response_type**  
  *string*  
  Required. Type of the response expected. Should be set to `code` as per OAuth 2.0 grant type.

- **scope**  
  *string*  
  Required. Should be set to `openid` as per OpenID Connect standard.

- **redirect_uri**  
  *string*  
  Required. Redirect URI of the user app where fabric Identity will redirect the user after a successful login.

- **state**  
  *string*  
  Required. A random string created by the user app to maintain state between the request and callback.

- **code_challenge_method**  
  *string*  
  Required only when using authorization code flow with PKCE. Fabric Identity supports `S256` only.

- **code_challenge**  
  *string*  
  Required only when using authorization code flow with PKCE. The challenge created by the user app.

### Response

- **302 Found**: A successful response will redirect the user to the hosted Login page. After login, fabric Identity redirects back to the `redirect_uri` with the authorization code and state as query parameters.
