> For the complete documentation index, see [llms.txt](https://developer.paywall.one/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.paywall.one/client-side-servisler/1.-yetkilendirme.md).

# 1. Yetkilendirme

## TempToken

<mark style="color:green;">`POST`</mark> `{{Base Adres}}/api/paywall/temptoken`&#x20;

{% hint style="info" %}
Önemli: **TempToken** servisini kullanabilmeniz için 'Header' alanında '**apikeypublic**' ve '**apiclientpublic**' parametrelerini göndermeniz gerekmektedir.\
\
[<mark style="color:green;">**PaymentAPI Adresi**</mark>](/ortam.md)
{% endhint %}

<table><thead><tr><th width="188">Parametre</th><th width="79">Tip</th><th width="107">Zorunlu</th><th width="403">Açıklama</th></tr></thead><tbody><tr><td>apikeypublic</td><td>string</td><td>Evet</td><td>Üye işyeri panelinden temin etmiş olduğunuz Public Key.</td></tr><tr><td>apiclientpublic</td><td>string</td><td>Evet</td><td>Üye işyeri panelinden temin etmiş olduğunuz Public Client.</td></tr></tbody></table>

#### Servise gönderilmesi gereken parametreler şu şekildedir:

<table><thead><tr><th width="244">Parametre</th><th width="157">Tip</th><th width="131">Zorunlu</th><th width="336">Açıklama</th></tr></thead><tbody><tr><td><pre><code>ClientCardSave
</code></pre></td><td>boolean</td><td>Evet</td><td>Token, client tarafta kart saklama için kullanılacak mı?</td></tr><tr><td><pre><code>ThreeDSession
</code></pre></td><td>boolean</td><td>Evet</td><td>Token, client tarafta 3D işlem yapmak için kullanılacak mı?</td></tr><tr><td><pre><code>ClientSdk
</code></pre></td><td>boolean</td><td>Evet</td><td>Token, Paywall'un client-side kütüphanesi için kullanılacak mı?</td></tr><tr><td><pre><code>ScopeBased
</code></pre></td><td>boolean</td><td>Evet</td><td>Token yetkilerini Scope parametresiyle belirlemek istediğiniz kullanmalısınız</td></tr><tr><td><pre><code>Scope
</code></pre></td><td>int</td><td>Evet/Hayır</td><td>Token yetkisi<br><br>0 = Yok<br>1 = ClientCardSave<br>2 = ThreeDSession<br>3 = ClientSdk</td></tr><tr><td><pre><code>ExpiryMin
</code></pre></td><td>int</td><td>Evet</td><td>Token, kaç dakika geçerli olacak?<br><br><mark style="color:blue;"><strong>0 ile 1440 arasında tanım yapılabilir</strong></mark></td></tr></tbody></table>

**Servise gönderilecek örnek&#x20;**<mark style="color:green;">**JSON**</mark>**&#x20;ve&#x20;**<mark style="color:green;">**örnek kodlar**</mark>**&#x20;aşağıdaki gibidir.**

{% tabs %}
{% tab title="JSON" %}
{% code lineNumbers="true" %}

```json5
{
    "ClientCardSave": true,
    "ThreeDSession": false,
    "ClientSdk": true,
    "ScopeBased": false,
    "Scope": 0,
    "ExpiryMin": 1440
}
```

{% endcode %}
{% endtab %}

{% tab title="C#" %}

```csharp
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

class Program
{
    static readonly HttpClient client = new HttpClient();

    static async Task Main()
    {
        var url = "{{BaseAddress}}/api/paywall/temptoken";
        var data = new
        {
            ClientCardSave = true,
            ThreeDSession = false,
            ClientSdk = true,
            ScopeBased = false,
            Scope = 0,
            ExpiryMin = 1440
        };

        var json = JsonConvert.SerializeObject(data);
        var content = new StringContent(json, Encoding.UTF8, "application/json");
        content.Headers.Add("apikeypublic", "%PUBLICKEY%");
        content.Headers.Add("apiclientpublic", "%PUBLICCLIENT%");

        var response = await client.PostAsync(url, content);
        var responseBody = await response.Content.ReadAsStringAsync();
        Console.WriteLine(responseBody);
    }
}
```

{% endtab %}

{% tab title="GO" %}

```go
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io/ioutil"
    "net/http"
)

type RequestData struct {
    ClientCardSave bool `json:"ClientCardSave"`
    ThreeDSession  bool `json:"ThreeDSession"`
    ClientSdk      bool `json:"ClientSdk"`
    ScopeBased     bool `json:"ScopeBased"`
    Scope          int  `json:"Scope"`
    ExpiryMin      int  `json:"ExpiryMin"`
}

func main() {
    url := "{{BaseAddress}}/api/paywall/temptoken"
    data := RequestData{
        ClientCardSave: true,
        ThreeDSession:  false,
        ClientSdk:      true,
        ScopeBased:     false,
        Scope:          0,
        ExpiryMin:      1440,
    }

    requestBody, _ := json.Marshal(data)
    client := &http.Client{}
    req, _ := http.NewRequest("POST", url, bytes.NewBuffer(requestBody))
    req.Header.Set("Content-Type", "application/json")
    req.Header.Set("apikeypublic", "%PUBLICKEY%")
    req.Header.Set("apiclientpublic", "%PUBLICCLIENT%")

    resp, _ := client.Do(req)
    defer resp.Body.Close()

    body, _ := ioutil.ReadAll(resp.Body)
    fmt.Println(string(body))
}
```

{% endtab %}

{% tab title="Java" %}

```java
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;
import org.json.JSONObject;

public class Main {
    public static void main(String[] args) {
        try {
            URL url = new URL("{{BaseAddress}}/api/paywall/temptoken");

            JSONObject jsonObject = new JSONObject();
            jsonObject.put("ClientCardSave", true);
            jsonObject.put("ThreeDSession", false);
            jsonObject.put("ClientSdk", true);
            jsonObject.put("ScopeBased", false);
            jsonObject.put("Scope", 0);
            jsonObject.put("ExpiryMin", 1440);

            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setDoOutput(true);
            conn.setRequestMethod("POST");
            conn.setRequestProperty("Content-Type", "application/json");
            conn.setRequestProperty("apikeypublic", "%PUBLICKEY%");
            conn.setRequestProperty("apiclientpublic", "%PUBLICCLIENT%");

            OutputStream os = conn.getOutputStream();
            os.write(jsonObject.toString().getBytes());
            os.flush();

            Scanner scan = new Scanner(conn.getInputStream());
            String entireResponse = "";
            while (scan.hasNext())
                entireResponse += scan.nextLine();
            System.out.println("Response : " + entireResponse);
            scan.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$url = '{{BaseAddress}}/api/paywall/temptoken';
$header = array(
    'Content-Type: application/json',
    'apikeypublic: %%',
    'apiclientpublic: %%'
);
$data = array(
    'ClientCardSave' => true,
    'ThreeDSession' => false,
    'ClientSdk' => true,
    'ScopeBased' => false,
    'Scope' => 0,
    'ExpiryMin' => 1440
);
$context = stream_context_create(array(
    'http' => array(
        'method' => 'POST',
        'header' => $header,
        'content' => json_encode($data),
    )
));
$result = file_get_contents($url, false, $context);
echo $result;
?>
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = '{{BaseAddress}}/api/paywall/temptoken'
headers = {
    'Content-Type': 'application/json',
    'apikeypublic': '%%',
    'apiclientpublic': '%%'
}
data = {
    'ClientCardSave': True,
    'ThreeDSession': False,
    'ClientSdk': True,
    'ScopeBased': False,
    'Scope': 0,
    'ExpiryMin': 1440
}

response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
```

{% endtab %}

{% tab title="Ruby" %}

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

url = URI("{{BaseAddress}}/api/paywall/temptoken")
http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["apikeypublic"] = '%%'
request["apiclientpublic"] = '%%'
request.body = JSON.dump({
  "ClientCardSave" => true,
  "ThreeDSession" => false,
  "ClientSdk" => true,
  "ScopeBased" => false,
  "Scope" => 0,
  "ExpiryMin" => 1440
})

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

{% endtab %}

{% tab title="TypeScript" %}

```typescript
import axios from 'axios';

const url = '{{BaseAddress}}/api/paywall/temptoken';
const headers = {
  'Content-Type': 'application/json',
  'apikeypublic': '%%',
  'apiclientpublic': '%%'
};
const data = {
  ClientCardSave: true,
  ThreeDSession: false,
  ClientSdk: true,
  ScopeBased: false,
  Scope: 0,
  ExpiryMin: 1440
};

axios.post(url, data, { headers })
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    console.error(error);
  });
```

{% endtab %}

{% tab title="Curl" %}

```sh
curl --location --request POST '{{BaseAddress}}/api/paywall/temptoken' \
--header 'Content-Type: application/json' \
--header 'apikeypublic: %%' \
--header 'apiclientpublic: %%' \
--data-raw '{
    "ClientCardSave": true,
    "ThreeDSession": false,
    "ClientSdk": true,
    "ScopeBased": false,
    "Scope": 0,
    "ExpiryMin": 1440
}'
```

{% endtab %}
{% endtabs %}

Servisten dönen parametreler şu şekildedir:

<table><thead><tr><th width="189">Parametre</th><th width="100.33333333333331">Tip</th><th>Açıklama</th></tr></thead><tbody><tr><td>ErrorCode</td><td>int</td><td>Hata kodu. İşlem başarılı ise '0' değerini döner.</td></tr><tr><td>Result</td><td>bool</td><td>True ya da false değeri döner. İşlem başarılı iste 'true' değerini döner.</td></tr><tr><td>Message</td><td>string</td><td>İşlem hatalıysa, bu hataya dair belirtilen mesajdır, locale parametresine göre dil desteği sunar.</td></tr><tr><td>Body</td><td>nesne</td><td>İşlem detay bilgileri</td></tr></tbody></table>

{% tabs %}
{% tab title="JSON" %}
{% code lineNumbers="true" %}

```json
{
    "ErrorCodeType": 1,
    "ErrorMessage": null,
    "ErrorCode": 0,
    "Result": true,
    "Message": "",
    "Body": {
        "TempTokenId": 14533994,
        "Token": "22ae3b5a-8eb0-41cc-88c7-219e25b95441",
        "ExpiryDateTime": "2024-06-13T22:25:08.0404774+03:00",
        "Scope": {
            "ClientCardSave": true,
            "ThreeDSession": false
        }
    }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}
