Skip to content

Instantly share code, notes, and snippets.

@rkh
Created November 19, 2012 17:08
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rkh/fbb99b638e9da27fe24d to your computer and use it in GitHub Desktop.
Save rkh/fbb99b638e9da27fe24d to your computer and use it in GitHub Desktop.
# Get a github token to prove that I am I. You can also acquire the token via in-browser OAuth.
$ curl -X POST -d '{"scopes": ["repo"], "note": "temporary token to prove that I am me."}' 'https://USER:PASSWORD@api.github.com/authorizations'
{
"url": "https://api.github.com/authorizations/826667",
"note": "temporary token to prove that I am me.",
"scopes": [
"repo"
],
"created_at": "2012-11-19T16:54:37Z",
"note_url": null,
"token": "GITHUB TOKEN", # <==== you want this
"updated_at": "2012-11-19T16:54:37Z",
"app": {
"url": "http://developer.github.com/v3/oauth/#oauth-authorizations-api",
"name": "temporary token to prove that I am me. (API)"
},
"id": 826667
}
# Now exchange that token for a Travis token. After this step the token can be removed from GitHub again.
[~]$ curl -d 'github_token=GITHUB TOKEN' 'https://api.travis-ci.com/auth/github'
{"access_token":"TRAVIS TOKEN"}
# Now you can use the Travis Token to do authenticated requests
[~]$ curl -H 'Authorization: token TRAVIS TOKEN' https://api.travis-ci.com/repos/travis-pro/travis-pro-ci
{
"repo": {
"description": "",
"id": 9,
"last_build_duration": 192,
"last_build_finished_at": "2012-11-13T10:07:53Z",
"last_build_id": 159398,
"last_build_language": null,
"last_build_number": "563",
"last_build_result": 1, # <===== 1 means passing
"last_build_started_at": "2012-11-13T10:04:41Z",
"slug": "travis-pro/travis-pro-ci"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment