Skip to content

Instantly share code, notes, and snippets.

@joschi
Last active September 28, 2023 04:27
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save joschi/21bc88207881581099570dd85588f7df to your computer and use it in GitHub Desktop.
Save joschi/21bc88207881581099570dd85588f7df to your computer and use it in GitHub Desktop.
Graylog access token login
# Create an access token for user "admin" with name "test-1234"
# POST /users/{username}/tokens/{name}
$ curl -i -u admin:admin -H 'Accept: application/json' -X POST 'http://127.0.0.1:12900/users/admin/tokens/test-1234?pretty=true'
HTTP/1.1 200 OK
X-Graylog-Node-ID: cd03ee44-b2a7-4824-be16-bb7456149dbd
Content-Type: application/json
Date: Mon, 08 Aug 2016 12:12:09 GMT
Content-Length: 139
{
"name" : "test-1234",
"token" : "8oe6l5b0db378b0qfsufa1j9jr4bnlvng1m6o998rag8fcmusj1",
"last_access" : "1970-01-01T00:00:00.000Z"
}
# Show existing access tokens for user "admin"
# GET /users/{username}/tokens/
$ curl -i -u admin:admin -H 'Accept: application/json' -X GET 'http://127.0.0.1:12900/users/admin/tokens/?pretty=true'
HTTP/1.1 200 OK
X-Graylog-Node-ID: cd03ee44-b2a7-4824-be16-bb7456149dbd
Content-Type: application/json
Date: Mon, 08 Aug 2016 12:12:11 GMT
Content-Length: 168
{
"tokens" : [ {
"name" : "test-1234",
"token" : "8oe6l5b0db378b0qfsufa1j9jr4bnlvng1m6o998rag8fcmusj1",
"last_access" : "1970-01-01T00:00:00.000Z"
} ]
}
# Use access token to access /system
# HTTP Authentication header with username == access token and password == "token"
$ curl -i -u 8oe6l5b0db378b0qfsufa1j9jr4bnlvng1m6o998rag8fcmusj1:token -H 'Accept: application/json' -X GET 'http://127.0.0.1:12900/system/?pretty=true'
HTTP/1.1 200 OK
X-Graylog-Node-ID: cd03ee44-b2a7-4824-be16-bb7456149dbd
X-Runtime-Microseconds: 446309
Content-Type: application/json
Date: Mon, 08 Aug 2016 12:14:46 GMT
Content-Length: 455
{
"facility" : "graylog-server",
"codename" : "Smuttynose",
"node_id" : "cd03ee44-b2a7-4824-be16-bb7456149dbd",
"cluster_id" : "b1ce3a29-6845-4e00-bd8c-d4499dc9e95d",
"version" : "2.1.0-beta.3-SNAPSHOT+203d8f3",
"started_at" : "2016-08-08T12:07:38.273Z",
"hostname" : "joschi-mbp15.lan",
"lifecycle" : "running",
"lb_status" : "alive",
"timezone" : "Europe/Berlin",
"operating_system" : "Mac OS X 10.11.6",
"is_processing" : true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment