summaryrefslogtreecommitdiff
path: root/octosentry/DeviceAuthModels.swift
diff options
context:
space:
mode:
Diffstat (limited to 'octosentry/DeviceAuthModels.swift')
-rw-r--r--octosentry/DeviceAuthModels.swift38
1 files changed, 38 insertions, 0 deletions
diff --git a/octosentry/DeviceAuthModels.swift b/octosentry/DeviceAuthModels.swift
new file mode 100644
index 0000000..dcd62c6
--- /dev/null
+++ b/octosentry/DeviceAuthModels.swift
@@ -0,0 +1,38 @@
+//
+// DeviceAuthModels.swift
+// octosentry
+//
+// Wire types for GitHub's OAuth 2.0 Device Authorization Grant
+// (RFC 8628): github.com/login/device/code and
+// github.com/login/oauth/access_token.
+//
+
+import Foundation
+
+nonisolated struct DeviceCodeResponse: Decodable {
+ let deviceCode: String
+ let userCode: String
+ let verificationUri: URL
+ let expiresIn: Int
+ let interval: Int
+
+ enum CodingKeys: String, CodingKey {
+ case deviceCode = "device_code"
+ case userCode = "user_code"
+ case verificationUri = "verification_uri"
+ case expiresIn = "expires_in"
+ case interval
+ }
+}
+
+nonisolated struct AccessTokenResponse: Decodable {
+ let accessToken: String?
+ let error: String?
+ let interval: Int?
+
+ enum CodingKeys: String, CodingKey {
+ case accessToken = "access_token"
+ case error
+ case interval
+ }
+}