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
use token::{Token, Lifetime, Bearer, Static, Refresh};
pub trait Provider {
type Lifetime: Lifetime;
type Token: Token<Self::Lifetime>;
fn auth_uri() -> &'static str;
fn token_uri() -> &'static str;
fn credentials_in_body() -> bool { false }
}
pub mod google {
use token::{Bearer, Expiring, Refresh};
use super::Provider;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Web;
impl Provider for Web {
type Lifetime = Expiring;
type Token = Bearer<Expiring>;
fn auth_uri() -> &'static str { "https://accounts.google.com/o/oauth2/v2/auth" }
fn token_uri() -> &'static str { "https://www.googleapis.com/oauth2/v4/token" }
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Installed;
impl Provider for Installed {
type Lifetime = Refresh;
type Token = Bearer<Refresh>;
fn auth_uri() -> &'static str { "https://accounts.google.com/o/oauth2/v2/auth" }
fn token_uri() -> &'static str { "https://www.googleapis.com/oauth2/v4/token" }
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct GitHub;
impl Provider for GitHub {
type Lifetime = Static;
type Token = Bearer<Static>;
fn auth_uri() -> &'static str { "https://github.com/login/oauth/authorize" }
fn token_uri() -> &'static str { "https://github.com/login/oauth/access_token" }
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Imgur;
impl Provider for Imgur {
type Lifetime = Refresh;
type Token = Bearer<Refresh>;
fn auth_uri() -> &'static str { "https://api.imgur.com/oauth2/authorize" }
fn token_uri() -> &'static str { "https://api.imgur.com/oauth2/token" }
}