Authenticate

2 minute read

POST /auth

Authentication

  • Basic

Responses

Code Datatype

200

Response schema

400

Error

401

Error

403

Error

404

Error

500

Error

Response schema

  • Content type: application/json

  • Response schema type: object

Field Name Type

access_token

string

organizations

array[object]

  • scopes

array[string]

  • uuid

string

  • name

string

expires_at

integer

Response example

{ "access_token": "EXAMPLE eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpZCI6IjYzMjIwNzg0YzUzODA3ZjVmZTc2Yjg4ZjZkNjdlMmExZTIxODlhZTEiLCJjbGllbnRfaWQiOiJUZXN0IENsaWVudCBJRCIsInVzZXJfaWQiOm51bGwsImV4cGlyZXMiOjEzODAwNDQ1NDIsInRva2VuX3R5cGUiOiJiZWFyZXIiLCJzY29wZSI6bnVsbH0.PcC4k8Q_etpU-J4yGFEuBUdeyMJhtpZFkVQ__sXpe78eSi7xTniqOOtgfWa73Y4sj5Npta8xPuDglH8Fueh_APZ53wGCiRE1P4nT4APQCOTbgjgCNXwjmP8znk9F76ID2WxThaMbmpsTTEkuyyUYQKCCdxlIcSbVvcLZUGKZ6-g", "organizations": [ { "uuid": "dc37c39f-731e-4100-b8bf-69dae9eb14aa", "name": "Codeship", "scopes": [ "build.read", "project.read" ] }, { "uuid": "dc37c39f-731e-4100-b8bf-69dae9eb14ab", "name": "Codeship Test Org", "scopes": [ "build.read", "build.write", "project.read", "project.write" ] } ], "expires_at": 1504275032 }

Code examples

cURL
Go
Java
Node
PHP
Python
Ruby
C#
curl --request POST \ --url https://api.codeship.com/v2/auth \ --header 'authorization: Basic dXNlckBjb2Rlc2hpcC5jb206MTIzNDU2Nzg=' \ --data '{}'
package main import ( "fmt" "strings" "net/http" "io/ioutil" ) func main() { url := "https://api.codeship.com/v2/auth" payload := strings.NewReader("{}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("authorization", "Basic dXNlckBjb2Rlc2hpcC5jb206MTIzNDU2Nzg=") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) }
OkHttpClient client = new OkHttpClient(); MediaType mediaType = MediaType.parse("application/octet-stream"); RequestBody body = RequestBody.create(mediaType, "{}"); Request request = new Request.Builder() .url("https://api.codeship.com/v2/auth") .post(body) .addHeader("authorization", "Basic dXNlckBjb2Rlc2hpcC5jb206MTIzNDU2Nzg=") .build(); Response response = client.newCall(request).execute();
var http = require("https"); var options = { "method": "POST", "hostname": "https://api.codeship.com", "port": null, "path": "/v2/auth", "headers": { "authorization": "Basic dXNlckBjb2Rlc2hpcC5jb206MTIzNDU2Nzg=" } }; var req = http.request(options, function (res) { var chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { var body = Buffer.concat(chunks); console.log(body.toString()); }); }); req.write("{}"); req.end();
<?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://api.codeship.com/v2/auth", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{}", CURLOPT_HTTPHEADER => array( "authorization: Basic dXNlckBjb2Rlc2hpcC5jb206MTIzNDU2Nzg=" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }
import http.client conn = http.client.HTTPSConnection("https://api.codeship.com") payload = "{}" headers = { 'authorization': "Basic dXNlckBjb2Rlc2hpcC5jb206MTIzNDU2Nzg=" } conn.request("POST", "/v2/auth", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8"))
require 'uri' require 'net/http' url = URI("https://api.codeship.com/v2/auth") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Post.new(url) request["authorization"] = 'Basic dXNlckBjb2Rlc2hpcC5jb206MTIzNDU2Nzg=' request.body = "{}" response = http.request(request) puts response.read_body
var client = new RestClient("https://api.codeship.com/v2/auth"); var request = new RestRequest(Method.POST); request.AddHeader("authorization", "Basic dXNlckBjb2Rlc2hpcC5jb206MTIzNDU2Nzg="); request.AddParameter("undefined", "{}", ParameterType.RequestBody); IRestResponse response = client.Execute(request);