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
use chrono::{DateTime, Utc};
use serde::Deserialize;

use super::PostToken;

#[derive(Clone, Debug)]
pub enum AuthInput {
    Uninitialized,
    Inoreader(InoreaderAuthInput),
    Google(GoogleAuthInput),
}

#[derive(Clone, Debug)]
pub struct InoreaderAuthInput {
    pub auth_code: String,
    pub redirect_url: String,
    pub client_id: String,
    pub client_secret: String,
}

#[derive(Clone, Debug)]
pub struct GoogleAuthInput {
    pub username: String,
    pub password: String,
}

#[derive(Clone, Debug)]
pub enum AuthData {
    Uninitialized,
    Inoreader(InoreaderAuth),
    Google(GoogleAuth),
}

#[derive(Clone, Debug)]
pub struct InoreaderAuth {
    pub client_id: String,
    pub client_secret: String,
    pub access_token: String,
    pub refresh_token: String,
    pub expires_at: DateTime<Utc>,
}

#[derive(Clone, Debug)]
pub struct GoogleAuth {
    pub username: String,
    pub password: String,
    pub auth_token: Option<String>,
    pub post_token: Option<PostToken>,
}

#[derive(Debug, Clone, Deserialize)]
pub struct OAuthResponse {
    pub access_token: String,
    pub token_type: String,
    pub expires_in: i64,
    pub refresh_token: String,
    pub scope: String,
}