8000 Use Circle-Token header for API authentication · marcoderama/circleci-docs@8fcac0d · GitHub
[go: up one dir, main page]

Skip to content

Commit 8fcac0d

Browse files
committed
Use Circle-Token header for API authentication
1 parent c847010 commit 8fcac0d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src-api/openapi-patch.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@
55
"x-codeSamples": [
66
{
77
"lang": "Node + Request",
8-
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/context',\n qs: {\n 'owner-id': 'c65b68ef-e73b-4bf2-be9a-7a322a9df150',\n 'page-token': 'next_page_token'\n },\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
8+
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/context',\n qs: {\n 'owner-id': 'c65b68ef-e73b-4bf2-be9a-7a322a9df150',\n 'page-token': 'next_page_token'\n },\n headers: {Circle-Token: '${CIRCLE_TOKEN}'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
99
},
1010
{
1111
"lang": "Python + Python3",
12-
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/context?owner-id=c65b68ef-e73b-4bf2-be9a-7a322a9df150&page-token=next_page_token\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
12+
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'Circle-Token': \"$CIRCLE_TOKEN\" }\n\nconn.request(\"GET\", \"/api/v2/context?owner-id=c65b68ef-e73b-4bf2-be9a-7a322a9df150&page-token=next_page_token\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
1313
},
1414
{
1515
"lang": "Go + Native",
16-
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/context?owner-id=c65b68ef-e73b-4bf2-be9a-7a322a9df150&page-token=next_page_token\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Print 905C ln(res)\n\tfmt.Println(string(body))\n\n}"
16+
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/context?owner-id=c65b68ef-e73b-4bf2-be9a-7a322a9df150&page-token=next_page_token\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"Circle-Token\", CIRCLE_TOKEN)\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
1717
},
1818
{
1919
"lang": "Shell + Curl",
20-
"source": "curl --request GET \\\n --url 'https://circleci.com/api/v2/context?owner-id=c65b68ef-e73b-4bf2-be9a-7a322a9df150&page-token=next_page_token' \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
20+
"source": "curl --request GET \\\n --url 'https://circleci.com/api/v2/context?owner-id=c65b68ef-e73b-4bf2-be9a-7a322a9df150&page-token=next_page_token' \\\n --header \"Circle-Token: $CIRCLE_TOKEN\""
2121
},
2222
{
2323
"lang": "Ruby + Native",
24-
"source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/context?owner-id=c65b68ef-e73b-4bf2-be9a-7a322a9df150&page-token=next_page_token\")\n\nhttp = Net::HTTP.new(url.host, url.port)\nhttp.use_ssl = true\nhttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\nrequest = Net::HTTP::Get.new(url)\nrequest[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body"
24+
"source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/context?owner-id=c65b68ef-e73b-4bf2-be9a-7a322a9df150&page-token=next_page_token\")\n\nhttp = Net::HTTP.new(url.host, url.port)\nhttp.use_ssl = true\nhttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\nrequest = Net::HTTP::Get.new(url)\nrequest[\"Circle-Token\"] = CIRCLE_TOKEN\n\nresponse = http.request(request)\nputs response.read_body"
2525
}
2626
]
2727
}

0 commit comments

Comments
 (0)
0