/
token_response.go
95 lines (73 loc) · 2.39 KB
/
token_response.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Code generated by go-swagger; DO NOT EDIT.
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// TokenResponse TokenResponse
//
// AccessTokenResponse.
//
// swagger:model TokenResponse
type TokenResponse struct {
// The access token issued by the authorization server.
// Required: true
AccessToken *string `json:"access_token"`
// The lifetime in seconds of the access token. For example, the value \"3600\" denotes that the access token will expire in one hour from the time the response was generated.
ExpiresIn int32 `json:"expires_in,omitempty"`
// id token
IDToken string `json:"id_token,omitempty"`
// The refresh token, which can be used to obtain new access tokens using the same authorization grant
RefreshToken string `json:"refresh_token,omitempty"`
// scope
Scope []string `json:"scope"`
// The access token type provides the client with the information required to successfully utilize the access token to make a protected resource request (along with type-specific attributes).
// Required: true
TokenType *string `json:"token_type"`
}
// Validate validates this token response
func (m *TokenResponse) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateAccessToken(formats); err != nil {
res = append(res, err)
}
if err := m.validateTokenType(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *TokenResponse) validateAccessToken(formats strfmt.Registry) error {
if err := validate.Required("access_token", "body", m.AccessToken); err != nil {
return err
}
return nil
}
func (m *TokenResponse) validateTokenType(formats strfmt.Registry) error {
if err := validate.Required("token_type", "body", m.TokenType); err != nil {
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *TokenResponse) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *TokenResponse) UnmarshalBinary(b []byte) error {
var res TokenResponse
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}