-
Notifications
You must be signed in to change notification settings - Fork 368
/
Copy pathdevice_response.go
94 lines (76 loc) · 2.62 KB
/
device_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
// Copyright © 2025 Ory Corp
// SPDX-License-Identifier: Apache-2.0
package fosite
import (
"net/http"
)
// DeviceResponse represents the device authorization response
type DeviceResponse struct {
Header http.Header
DeviceCode string `json:"device_code"`
UserCode string `json:"user_code"`
VerificationURI string `json:"verification_uri"`
VerificationURIComplete string `json:"verification_uri_complete,omitempty"`
ExpiresIn int64 `json:"expires_in"`
Interval int `json:"interval,omitempty"`
}
// NewDeviceResponse returns a new DeviceResponse
func NewDeviceResponse() *DeviceResponse {
return &DeviceResponse{}
}
// GetDeviceCode returns the response's device_code
func (d *DeviceResponse) GetDeviceCode() string {
return d.DeviceCode
}
// SetDeviceCode sets the response's device_code
func (d *DeviceResponse) SetDeviceCode(code string) {
d.DeviceCode = code
}
// GetUserCode returns the response's user_code
func (d *DeviceResponse) GetUserCode() string {
return d.UserCode
}
// SetUserCode sets the response's user_code
func (d *DeviceResponse) SetUserCode(code string) {
d.UserCode = code
}
// GetVerificationURI returns the response's verification uri
func (d *DeviceResponse) GetVerificationURI() string {
return d.VerificationURI
}
// SetVerificationURI sets the response's verification uri
func (d *DeviceResponse) SetVerificationURI(uri string) {
d.VerificationURI = uri
}
// GetVerificationURIComplete returns the response's complete verification uri if set
func (d *DeviceResponse) GetVerificationURIComplete() string {
return d.VerificationURIComplete
}
// SetVerificationURIComplete sets the response's complete verification uri
func (d *DeviceResponse) SetVerificationURIComplete(uri string) {
d.VerificationURIComplete = uri
}
// GetExpiresIn returns the response's device code and user code lifetime in seconds if set
func (d *DeviceResponse) GetExpiresIn() int64 {
return d.ExpiresIn
}
// SetExpiresIn sets the response's device code and user code lifetime in seconds
func (d *DeviceResponse) SetExpiresIn(seconds int64) {
d.ExpiresIn = seconds
}
// GetInterval returns the response's polling interval if set
func (d *DeviceResponse) GetInterval() int {
return d.Interval
}
// SetInterval sets the response's polling interval
func (d *DeviceResponse) SetInterval(seconds int) {
d.Interval = seconds
}
// GetHeader returns the response's headers
func (d *DeviceResponse) GetHeader() http.Header {
return d.Header
}
// AddHeader adds a header to the response
func (d *DeviceResponse) AddHeader(key, value string) {
d.Header.Add(key, value)
}