2013-12-17 19 views
5

Ich versuche, mich mit der GoodData API zu authentifizieren/einloggen, aber ich habe Probleme. Auf der Gooddata API-Dokumentation Website (docs.gooddata.apiary.io) sagt, dass es, um es zu:Wie authentifiziere ich mich bei der GoodData API?

URL:

https://secure.gooddata.com/gdc/account/login

Headers:

Accept: application/json 
Content-Type: application/json 

JSON Körper:

{ "postUserLogin": { "login": "[email protected]", "Passwort": "IhrPasswort", "erinnern": 1}}

ich die Antwort „Privat bekommen API, bitte privaten Hash bereitstellen. " Irgendwelche Ideen?

Antwort

8

Die aktualisierte Gooddata API-Dokumentation und API-Konsole bei https://developer.gooddata.com/api

Die Login-URL für diesen Aufruf ist eigentlich https://secure.gooddata.com/gdc/account/login

Mit der gleichen Nutzlast (Ihre Anmeldeinformationen anstelle der Probe) befindet können Sie sich anmelden und erhalte das SST-Token, das im SetCookie-Header zurückgegeben wird.

Bitte denken Sie daran, den Prozess melden ist:

  1. Ihre Zugangsdaten zum Login-Ressource POST wie hier erwähnt
  2. SST Token zurückgegeben wird, zurück in SetCookie Header
  3. die Token-Ressource mit SST Token GET in Ihr Kopf TT Token
  4. Verwenden Sie die TT-Token in Ihrem API-Aufrufe Header zu erhalten: -cookie

Bitte beachten Sie, dass TT Token nur eine begrenzte Gültigkeit hat. Sobald Sie 401 Nicht autorisierte Antwort erhalten haben, müssen Sie ein neues TT-Token in der folgenden Ressource abholen, wobei das SST-Token in der Anrufkopfzeile angegeben wird.

2

über die Gooddata Apiary Ich habe beispielsweise in CURL

1. Schritt - POST zu https://secure.gooddata.com/gdc/account/login:

[email protected]:~$ curl --include --header "Accept: application/json" --header "Content-Type: application/json" --request POST --data-binary "{\"postUserLogin\":{\"login\":\"[email protected]\",\"password\":\"`cat my_pass.txt`\",\"remember\":1}}" "https://secure.gooddata.com/gdc/account/login" 
HTTP/1.1 200 OK 
X-GDC-REQUEST: 7AEoVKre3lTF8sUV 
Server: Apache 
Set-Cookie: GDCAuthTT=; path=/gdc; expires=Sat, 07-Sep-2013 22:16:26 GMT; secure; HttpOnly 
Set-Cookie: GDCAuthSST=jcftYGCC3u6pkNRK; path=/gdc/account; expires=Wed, 23-Oct-2013 22:16:26 GMT; secure; HttpOnly 
Expires: Mon, 26 Jul 1997 05:00:00 GMT 
Cache-Control: no-store, no-cache, must-revalidate, max-age=0 
Pragma: no-cache 
P3P: CP='IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT' 
X-GDC-REQUEST-TIME: 69 
Content-Type: application/json;charset=UTF-8 
Content-Length: 143 
Accept-Ranges: bytes 
Date: Mon, 07 Oct 2013 22:16:26 GMT 
X-Varnish: 2109577795 
Age: 0 
Via: 1.1 varnish 
Connection: keep-alive 

{"userLogin":{"profile":"/gdc/account/profile/254c399a3f5131b7026313d4f8761410","state":"/gdc/account/login/254c399a3f5131b7026313d4f8761410"}} 

zweiter Schritt ist GDCAuthTT mit SST aus der Antwort vom ersten Schritt zu erhalten:

[email protected]:~$ curl --include --header "Cookie: $Version=0; GDCAuthSST=jcftYGCC3u6pkNRK; $Path=/gdc/account" --header "Accept: application/json" --header "Content-Type: application/json" https://secure.gooddata.com/gdc/account/tokenHTTP/1.1 200 OK 
X-GDC-REQUEST: GqPnYyk3pKAW5eju 
Server: Apache 
Set-Cookie: GDCAuthTT=h3CUUg72U2SLhL7Tghj_TVnba6byjgj3L78aJkSFuoji_0DiqXGRYY7C1zWDa-2yIa0Aj3-MuVlWPdNSx7N7CDzM7w21Fl6OaMjuF-98bV6cRx34HW-ql6IGt6ufWo_U5fQa2QqU6b-F0MsGE6orDC6ZMt2anJQdATNYsHfELiB7ImwiOiIwIiwidSI6IjE3Mzk4NyIsImsiOiJiZWQyZWU1ZS05YzYxLTRhNWMtOWJlNi05ZTAxZDQ4NjI5NmEiLCJ1aWQiOiIyNTRjMzk5YTNmNTEzMWI3MDI2MzEzZDRmODc2MTQxMCIsInYiOjEzODExODQ4MTZ9; path=/gdc; secure; HttpOnly 
Expires: Mon, 26 Jul 1997 05:00:00 GMT 
Cache-Control: no-store, no-cache, must-revalidate, max-age=0 
Pragma: no-cache 
P3P: CP='IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT' 
X-GDC-TIMESTAMP: 600 
X-GDC-REQUEST-TIME: 20 
Content-Type: application/json;charset=UTF-8 
Content-Length: 2 
Accept-Ranges: bytes 
Date: Mon, 07 Oct 2013 22:16:56 GMT 
X-Varnish: 1661889108 
Age: 0 
Via: 1.1 varnish 
Connection: keep-alive 

Und dann können Sie alle anderen Anrufe benutzen, um Ihre GDCAuthTT verwenden, aber diese GDCAuthTT Gültigkeit hat nur 10 Minuten und nach 10 Minuten werden Sie 401 und Sie haben wieder vorherigen Befehl rufen nach neuen GDCAuthTT

1

oder Sie können python und Code sollte wie folgt

[email protected]:~$ python 
Python 2.7.3 (default, Jan 2 2013, 13:56:14) 
[GCC 4.7.2] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
>>> from urllib2 import Request, urlopen 
>>> from json import dumps 
>>> values = dumps({"postUserLogin":{"login":"[email protected]","password":"secredpassword","remember":1}}) 
>>> headers = {"Accept": "application/json", "Content-Type": "application/json"} 
>>> request = Request("https://secure.gooddata.com/gdc/account/login", data=values, headers=headers) 
>>> response_body = urlopen(request) 
>>> print response_body.read() 
{"userLogin":{"profile":"/gdc/account/profile/254c399a3f5131b7026313d4f8761410","state":"/gdc/account/login/254c399a3f5131b7026313d4f8761410"}} 
>>> print response_body.info() 
X-GDC-REQUEST: FnETpOmoAPELJoS1 
Server: Apache 
Set-Cookie: GDCAuthTT=; path=/gdc; expires=Wed, 08-Jan-2014 20:07:00 GMT; secure; HttpOnly 
Set-Cookie: GDCAuthSST=QubuMlx3byz6lta1; path=/gdc/account; expires=Sun, 23-Feb-2014 20:07:00 GMT; secure; HttpOnly 
Expires: Mon, 26 Jul 1997 05:00:00 GMT 
Cache-Control: no-store, no-cache, must-revalidate, max-age=0 
Pragma: no-cache 
P3P: CP='IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT' 
X-GDC-LOG-HEADER: 
X-GDC-REQUEST-TIME: 53 
Content-Type: application/json;charset=UTF-8 
Content-Length: 143 
Accept-Ranges: bytes 
Date: Fri, 07 Feb 2014 20:07:00 GMT 
X-Varnish: 1076092393 
Age: 0 
Via: 1.1 varnish 
Connection: close 

>>> headers = {"Cookie": "$Version=0; GDCAuthSST=QubuMlx3byz6lta1; $Path=/gdc/account", "Accept": "application/json", "Content-Type": "application/json"} 
>>> request = Request("https://secure.gooddata.com/gdc/account/token", headers=headers) 
>>> response_body = urlopen(request) 
>>> print response_body.read() 
{} 
>>> print response_body.info() 
X-GDC-REQUEST: IyuefQK4mMIm4Vqr 
Server: Apache 
Set-Cookie: GDCAuthTT=VL_Bum5jjd8cEtFUa6XF5tfVmmiFDn7ZyB6a95kEuhzlQw-D67RIL_8u1E9e_z3yDx2bgHrsVNwX6zY1XRzsVpgtvC7HY2JBWiTtq63_Y-XxQwN9cO9RJO6GwM8WnshREwXXgzUk0vr9U4Gg-a4FnEs5NR4ySWOW1bhjnFSJFG17ImwiOiIwIiwidSI6IjE3Mzk4NyIsImsiOiIxYTZiNzc4ZC0yNDkyLTQ2OWEtODliYy1lNWQ1OWU1ODAyNDUiLCJ1aWQiOiIyNTRjMzk5YTNmNTEzMWI3MDI2MzEzZDRmODc2MTQxMCIsInYiOjEzOTE4MDQzMjV9; path=/gdc; secure; HttpOnly 
Expires: Mon, 26 Jul 1997 05:00:00 GMT 
Cache-Control: no-store, no-cache, must-revalidate, max-age=0 
Pragma: no-cache 
P3P: CP='IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT' 
X-GDC-TIMESTAMP: 600 
X-GDC-LOG-HEADER: 
X-GDC-REQUEST-TIME: 30 
Content-Type: application/json;charset=UTF-8 
Content-Length: 2 
Accept-Ranges: bytes 
Date: Fri, 07 Feb 2014 20:08:45 GMT 
X-Varnish: 1076094531 
Age: 0 
Via: 1.1 varnish 
Connection: close 
aussehen verwenden
Verwandte Themen