Some details info
[ouya-store-api.git] / api / devs.ouya.tv / api-v1-sessions.rst
1 =============================================
2 ``POST https://devs.ouya.tv/api/v1/sessions``
3 =============================================
4
5 Log in and obtain a session token.
6
7 This token is stored in the console and used in the
8 ``X-OUYA-AuthToken`` and ``X-Token`` headers as well as the
9 ``auth_token`` GET parameter.
10
11
12 Usage
13 =====
14
15 #. After logging with an existing account
16 #. After new user registration
17
18
19 HTTP request
20 ============
21 Protocol
22   ``https``
23 Method
24   ``POST``
25 Host
26   ``devs.ouya.tv``
27 Path
28   ``/api/v1/sessions``
29 Headers
30   ``Accept-Encoding``
31   ``User-Agent``
32   ``X-OUYA-Console-Id``
33   ``X-OUYA-Device``
34
35   ``Content-Type``
36     ``application/x-www-form-urlencoded``
37 POST parameters
38   ``username``
39     User name used to log in
40   ``password``
41     User password
42
43 HTTP response
44 =============
45
46 Success
47 -------
48 When the user logged in successfully.
49
50 .. note:: If the user is already logged in, the old ``auth_token`` is returned.
51           No new token is issued in this case.
52
53 Status code
54   ``200 OK`` 
55 Content type
56   ``application/json; charset=utf-8``
57
58 Response body example:
59
60 .. include:: api-v1-sessions.response-valid.json
61    :code:
62
63
64 Invalid login data
65 ------------------
66 When the login data are invalid.
67
68 Also seen when the data were not available yet (e.g. user freshly registered)
69 but the processes on the server were not finished yet.
70 The OUYA simply tried the request a second time.
71
72 Status code
73   ``400 Bad Request``
74 Content type
75   ``application/json; charset=utf-8``
76
77 Response body example:
78
79 .. include:: api-v1-sessions.response-invalid.json
80    :code: