Chilkat Online Tools

unicodeC / Broker API / client_id

Back to Collection Items

#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkHttpResponseW.h>

void ChilkatSample(void)
    {
    HCkHttpW http;
    BOOL success;
    HCkJsonObjectW json;
    HCkStringBuilderW sbRequestBody;
    HCkHttpResponseW resp;

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    http = CkHttpW_Create();

    CkHttpW_putBasicAuth(http,TRUE);
    CkHttpW_putLogin(http,L"{{api_key}}");
    CkHttpW_putPassword(http,L"{{api_secret}}");

    // Use this online tool to generate code from sample JSON: Generate Code to Create JSON

    // The following JSON is sent in the request body.

    // {
    //   "response_type": "token",
    //   "redirect_uri": "www.example.com/oauth_redirect",
    //   "scope": "general"
    // }

    json = CkJsonObjectW_Create();
    CkJsonObjectW_UpdateString(json,L"response_type",L"token");
    CkJsonObjectW_UpdateString(json,L"redirect_uri",L"www.example.com/oauth_redirect");
    CkJsonObjectW_UpdateString(json,L"scope",L"general");

    sbRequestBody = CkStringBuilderW_Create();
    CkJsonObjectW_EmitSb(json,sbRequestBody);

    resp = CkHttpW_PTextSb(http,L"GET",L"https:///v1/oauth/clients/:client_id",sbRequestBody,L"utf-8",L"application/json",FALSE,FALSE);
    if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkJsonObjectW_Dispose(json);
        CkStringBuilderW_Dispose(sbRequestBody);
        return;
    }

    wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
    wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
    CkHttpResponseW_Dispose(resp);


    CkHttpW_Dispose(http);
    CkJsonObjectW_Dispose(json);
    CkStringBuilderW_Dispose(sbRequestBody);

    }

Curl Command

curl -X GET
	-u '{{api_key}}:{{api_secret}}'
	-d '{
  "response_type": "token",
  "redirect_uri": "www.example.com/oauth_redirect",
  "scope": "general"
}'
https:///v1/oauth/clients/:client_id

Postman Collection Item JSON

{
  "name": "client_id",
  "protocolProfileBehavior": {
    "disableBodyPruning": true
  },
  "request": {
    "method": "GET",
    "header": [
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n  \"response_type\": \"token\",\n  \"redirect_uri\": \"www.example.com/oauth_redirect\",\n  \"scope\": \"general\"\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "/v1/oauth/clients/:client_id",
      "path": [
        "v1",
        "oauth",
        "clients",
        ":client_id"
      ],
      "variable": [
        {
          "key": "client_id",
          "value": null
        }
      ]
    },
    "description": "| Attribute         | Type   | Notes                                  |\n| ----------------- | ------ | -------------------------------------- |\n| `response_type`   | string | ENUM: `code` or `token`                |\n| `redirect_uri`    | string | Redirect URI of the OAuth flow         |\n| `scope`           | string | Requested scopes by the OAuth flow     |"
  },
  "response": [
  ]
}