-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathConfigurationLoader.Defaults.cs
executable file
·138 lines (127 loc) · 5.76 KB
/
ConfigurationLoader.Defaults.cs
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
namespace OAuthServer;
/// <summary>
/// Configuration settings from the providers API descriptions.
/// These are not expected to be changed, but can be overridden via config.json
/// </summary>
public static class DefaultConfigurations
{
/// <summary>
/// The setup for Windows Live endpoint
/// </summary>
/// <remarks>Managed from: https://portal.azure.com</remarks>
private static readonly ServiceDefault WindowsLive = new ServiceDefault(
"WL",
Name: "Microsoft OneDrive (Live Connect API)",
AuthUrl: "https://login.live.com/oauth20_token.srf",
LoginUrl: "https://login.live.com/oauth20_authorize.srf",
Scope: "wl.offline_access wl.skydrive_update wl.skydrive",
ServiceLink: "https://onedrive.live.com",
Notes: "<p style=\"font-size: small\">By using the OAuth login service for OneDrive you agree to the <a href=\"https://www.microsoft.com/en-us/servicesagreement\" target=\"_blank\">Microsoft Service Agreement</a> and <a href=\"https://privacy.microsoft.com/en-us/privacystatement\" target=\"_blank\">Microsoft Online Privacy Statement</a></p>"
);
/// <summary>
/// The setup for MS Graph API
/// </summary>
/// <remarks>Managed from: https://portal.azure.com</remarks>
private static readonly ServiceDefault MicrosoftGraph = new ServiceDefault(
"MSGRAPH",
Name: "Microsoft OneDrive (Microsoft Graph API)",
AuthUrl: "https://login.microsoftonline.com/common/oauth2/v2.0/token",
LoginUrl: "https://login.microsoftonline.com/common/oauth2/v2.0/authorize",
Scope: "offline_access Files.ReadWrite",
ServiceLink: "https://onedrive.live.com"
);
/// <summary>
/// The setup for Google Drive API
/// </summary>
/// <remarks>Managed from: https://console.developers.google.com</remarks>
private static readonly ServiceDefault GoogleDrive = new ServiceDefault(
"GD",
Name: "Google Drive (limited)",
AuthUrl: "https://www.googleapis.com/oauth2/v3/token",
LoginUrl: "https://accounts.google.com/o/oauth2/auth",
Scope: "https://www.googleapis.com/auth/drive.file",
ExtraUrl: "&access_type=offline&approval_prompt=force",
ServiceLink: "https://drive.google.com",
DeAuthLink: "https://security.google.com/settings/security/permissions",
BrandImage: "/google-btn.png"
);
/// <summary>
/// The setup for Google Cloud Services API
/// </summary>
/// <remarks>Managed from: https://console.developers.google.com</remarks>
private static readonly ServiceDefault GoogleCloudStorage = new ServiceDefault(
"GCS",
Name: "Google Cloud Storage",
AuthUrl: "https://www.googleapis.com/oauth2/v3/token",
LoginUrl: "https://accounts.google.com/o/oauth2/auth",
Scope: "https://www.googleapis.com/auth/devstorage.read_write",
ExtraUrl: "&access_type=offline&approval_prompt=force",
ServiceLink: "https://cloud.google.com/storage/",
DeAuthLink: "https://security.google.com/settings/security/permissions",
BrandImage: "/google-btn.png"
);
/// <summary>
/// The setup for box.com API
/// </summary>
/// <remarks>Managed from: https://app.box.com/developers/console</remarks>
private static readonly ServiceDefault BoxCom = new ServiceDefault(
"BOX",
Name: "Box.com",
AuthUrl: "https://api.box.com/oauth2/token",
LoginUrl: "https://app.box.com/api/oauth2/authorize",
Scope: "root_readwrite",
ServiceLink: "https://www.box.com/pricing/personal/"
);
/// <summary>
/// The setup for the Dropbox API
/// </summary>
/// <remarks>Managed from: https://www.dropbox.com/developers/apps</remarks>
private static readonly ServiceDefault Dropbox = new ServiceDefault(
"DROPBOX",
Name: "Dropbox",
AuthUrl: "https://api.dropboxapi.com/oauth2/token",
LoginUrl: "https://www.dropbox.com/oauth2/authorize",
Scope: "files.content.write files.content.read files.metadata.read files.metadata.write",
ExtraUrl: "&token_access_type=offline",
ServiceLink: "https://dropbox.com",
NoStateForTokenRequest: true,
NoRedirectUriForRefreshRequest: true
);
/// <summary>
/// The setup for Jottacloud API
/// </summary>
/// <remarks>https://www.jottacloud.com/web/account</remarks>
private static readonly ServiceDefault Jottacloud = new ServiceDefault(
"JOTTA",
Name: "Jottacloud",
CliToken: true,
Scope: "openid offline_access",
ServiceLink: "https://jottacloud.com"
);
/// <summary>
/// The setup for pCloud API
/// </summary>
/// <remarks>Managed from: https://docs.pcloud.com/my_apps/</remarks>
private static readonly ServiceDefault pCloud = new ServiceDefault(
"PCLOUD",
Name: "pCloud",
AuthUrl: "https://api.pcloud.com/oauth2_token",
LoginUrl: "https://my.pcloud.com/oauth2/authorize",
// Scope: "root_readwrite",
ServiceLink: "https://pcloud.com/",
AccessTokenOnly: true,
UseHostnameFromCallback: true,
AdditionalElements: "locationid,hostname"
);
/// <summary>
/// Loads all known service defauls via reflection
/// </summary>
/// <returns>A lookup table with known service configuration defaults</returns>
public static IReadOnlyDictionary<string, ServiceDefault> AllServices
= typeof(DefaultConfigurations)
.GetFields(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public)
.Where(x => x.FieldType == typeof(ServiceDefault))
.Select(x => x.GetValue(null))
.OfType<ServiceDefault>()
.ToDictionary(x => x.Id);
}