aboutsummaryrefslogtreecommitdiff
path: root/octosentry/DeviceAuthModels.swift
blob: dcd62c6af09fcaab65b98272217ed0d1be362e57 (plain) (blame)
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
//
//  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
    }
}