@@ -8,14 +8,54 @@ import (
8
8
type AuthenticationToken struct {
9
9
Success bool
10
10
RequestToken string `json:"request_token"`
11
- ExpiresAt string `json:"expires_at"`
11
+ ExpiresAt string `json:"expires_at,omitempty "`
12
12
}
13
13
14
- // GetNewToken generates a valid request token for user based authentication
14
+ // AuthenticationSession struct
15
+ type AuthenticationSession struct {
16
+ Success bool
17
+ SessionID string `json:"session_id"`
18
+ }
19
+
20
+ // AuthenticationGuestSession struct
21
+ type AuthenticationGuestSession struct {
22
+ Success bool
23
+ GuestSessionID string `json:"guest_session_id"`
24
+ ExpiresAt string `json:"expires_at"`
25
+ }
26
+
27
+ // GetAuthToken generates a valid request token for user based authentication
15
28
// http://docs.themoviedb.apiary.io/#reference/authentication/authenticationtokennew/get
16
- func (tmdb * TMDb ) GetNewToken () (* AuthenticationToken , error ) {
29
+ func (tmdb * TMDb ) GetAuthToken () (* AuthenticationToken , error ) {
17
30
var token AuthenticationToken
18
31
uri := fmt .Sprintf ("%s/authentication/token/new?api_key=%s" , baseURL , tmdb .apiKey )
19
32
result , err := getTmdb (uri , & token )
20
33
return result .(* AuthenticationToken ), err
21
34
}
35
+
36
+ // GetAuthValidateToken authenticates a user with a TMDb username and password
37
+ // http://docs.themoviedb.apiary.io/#reference/authentication/authenticationtokenvalidatewithlogin/get
38
+ func (tmdb * TMDb ) GetAuthValidateToken (token , user , password string ) (* AuthenticationToken , error ) {
39
+ var validToken AuthenticationToken
40
+ uri := fmt .Sprintf ("%s/authentication/token/validate_with_login?api_key=%s&request_token=%s&username=%s&password=%s" , baseURL , tmdb .apiKey , token , user , password )
41
+ result , err := getTmdb (uri , & validToken )
42
+ return result .(* AuthenticationToken ), err
43
+ }
44
+
45
+ // GetAuthSession generates a session id for user based authentication
46
+ // http://docs.themoviedb.apiary.io/#reference/authentication/authenticationsessionnew/get
47
+ func (tmdb * TMDb ) GetAuthSession (token string ) (* AuthenticationSession , error ) {
48
+ var session AuthenticationSession
49
+ uri := fmt .Sprintf ("%s/authentication/session/new?api_key=%s&request_token=%s" , baseURL , tmdb .apiKey , token )
50
+ result , err := getTmdb (uri , & session )
51
+ return result .(* AuthenticationSession ), err
52
+ }
53
+
54
+ // GetAuthGuestSession generates a valid request token for user based authentication
55
+ // http://docs.themoviedb.apiary.io/#reference/authentication/authenticationguestsessionnew/get
56
+ func (tmdb * TMDb ) GetAuthGuestSession () (* AuthenticationGuestSession , error ) {
57
+ var session AuthenticationGuestSession
58
+ uri := fmt .Sprintf ("%s/authentication/guest_session/new?api_key=%s" , baseURL , tmdb .apiKey )
59
+ result , err := getTmdb (uri , & session )
60
+ return result .(* AuthenticationGuestSession ), err
61
+ }
0 commit comments