Hi

Unfortunately based on our security policy I can't share more that I did it 
before, but now I show the full process.

Norbert

[root@nagios-master ~]# curl -u root:XX -H 'Accept: application/json' -X 
POST 'http://IP:9000/api/users/root/tokens/monitor?pretty=true' -i
HTTP/1.1 200 OK
X-Graylog-Node-ID: 0ccf3479-4c38-401b-84a3-dbcfd4badcdb
Content-Type: application/json
Date: Mon, 09 Jan 2017 12:01:47 GMT
Content-Length: 138

{
  "name" : "monitor",
  "token" : "1nju0tc889slbv1c86n798fdjdgrs4jl7dk3gnsk1uc807bcj64u",
  "last_access" : "1970-01-01T00:00:00.000Z"
}[root@nagios-master ~]#
[root@nagios-master ~]# curl  http://IP:9000/api/system  -u 
1nju0tc889slbv1c86n798fdjdgrs4jl7dk3gnsk1uc807bcj64u:token  -i
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Basic realm="Graylog Server"
X-Graylog-Node-ID: 0ccf3479-4c38-401b-84a3-dbcfd4badcdb
X-Runtime-Microseconds: 364
Date: Mon, 09 Jan 2017 12:02:16 GMT
Content-Length: 0

[root@nagios-master ~]# curl  http://IP:9000/api/system  -u root:XX  -i
HTTP/1.1 200 OK
X-Graylog-Node-ID: 0ccf3479-4c38-401b-84a3-dbcfd4badcdb
X-Runtime-Microseconds: 1115
Content-Type: application/json
Date: Mon, 09 Jan 2017 12:02:33 GMT
Content-Length: 402

{"facility":"graylog-server","codename":"Smuttynose","node_id":"0ccf3479-4c38-401b-84a3-dbcfd4badcdb","cluster_id":"c43b5005-0262-4ac5-8afe-6ead71f1ae00","version":"2.1.2+50e449a","started_at":"2017-01-05T09:40:58.192Z","hostname":"XX","lifecycle":"running","lb_status":"alive","timezone":"Europe/Budapest","operating_system":"Linux
 
3.10.0-514.2.2.el7.x86_64","is_processing":true}[root@nagios-master ~]#
[root@nagios-master ~]# curl -u root:XX -H 'Accept: application/json' -X 
GET 'http://IP:9000/api/users/root/tokens/?pretty=true' -i
HTTP/1.1 200 OK
X-Graylog-Node-ID: 0ccf3479-4c38-401b-84a3-dbcfd4badcdb
Content-Type: application/json
Date: Mon, 09 Jan 2017 12:02:56 GMT
Content-Length: 318

{
  "tokens" : [ {
    "name" : "XX",
    "token" : "XX",
    "last_access" : "1970-01-01T00:00:00.000Z"
  }, {
    "name" : "monitor",
    "token" : "1nju0tc889slbv1c86n798fdjdgrs4jl7dk3gnsk1uc807bcj64u",
    "last_access" : "1970-01-01T00:00:00.000Z"
  } ]
}[root@nagios-master ~]#


2017. január 9., hétfő 12:39:42 UTC+1 időpontban Jochen Schalanda a 
következőt írta:
>
> Hi Norbert,
>
> see 
> http://docs.graylog.org/en/2.1/pages/configuration/rest_api.html#creating-and-using-access-token
>  
> for instructions about using access tokens with the Graylog REST API.
>
> If, after reading the documentation carefully, you're still unable to make 
> the access token work, please post your complete curl commands and do not 
> obfuscate any data (except maybe the username and the password you're 
> creating the token with).
>
> Cheers,
> Jochen
>
> On Monday, 9 January 2017 12:03:45 UTC+1, Norbert Kiss wrote:
>>
>> Hi
>>
>> What I did wrong?
>>
>> I create a token, and if I try to use the token to get an url under 
>> /api/system , I get Unauthorized back.
>>
>> Thanks,
>>
>> Norbert
>>
>>
>> curl -u USER:PASS -H 'Accept: application/json' -X GET 
>> 'http://IP:9000/api/users/USER/tokens?pretty=true'
>> {
>>   "tokens" : [ {
>>     "name" : "NAME",
>>     "token" : "TOKENID",
>>     "last_access" : "1970-01-01T00:00:00.000Z"
>>   } ]
>> }
>>
>> curl http://IP:9000/api/system -u TOKENID:token -i
>> HTTP/1.1 401 Unauthorized
>> WWW-Authenticate: Basic realm="Graylog Server"
>> X-Graylog-Node-ID: XX
>> X-Runtime-Microseconds: 490
>> Date: Mon, 09 Jan 2017 10:58:23 GMT
>> Content-Length: 0
>>
>>
>> curl http://IP:9000/api/system -u USER:PASS -i
>> HTTP/1.1 200 OK
>> X-Graylog-Node-ID: XX
>> X-Runtime-Microseconds: 244491
>> Content-Type: application/json
>> Date: Mon, 09 Jan 2017 10:58:40 GMT
>> Content-Length: 402
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Graylog Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to graylog2+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/graylog2/21b13aaf-bac4-469d-9704-6317ed1fb759%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to