6
6
package endpoints
7
7
8
8
import (
9
- "strings "
9
+ "net/url "
10
10
11
11
"golang.org/x/oauth2"
12
12
)
@@ -17,6 +17,30 @@ var Amazon = oauth2.Endpoint{
17
17
TokenURL : "https://api.amazon.com/auth/o2/token" ,
18
18
}
19
19
20
+ // Apple is the endpoint for "Sign in with Apple".
21
+ //
22
+ // Documentation: https://developer.apple.com/documentation/signinwithapplerestapi
23
+ var Apple = oauth2.Endpoint {
24
+ AuthURL : "https://appleid.apple.com/auth/authorize" ,
25
+ TokenURL : "https://appleid.apple.com/auth/token" ,
26
+ }
27
+
28
+ // Asana is the endpoint for Asana.
29
+ //
30
+ // Documentation: https://developers.asana.com/docs/oauth
31
+ var Asana = oauth2.Endpoint {
32
+ AuthURL : "https://app.asana.com/-/oauth_authorize" ,
33
+ TokenURL : "https://app.asana.com/-/oauth_token" ,
34
+ }
35
+
36
+ // Badgr is the endpoint for Canvas Badges.
37
+ //
38
+ // Documentation: https://community.canvaslms.com/t5/Canvas-Badges-Credentials/Developers-Build-an-app-that-integrates-with-the-Canvas-Badges/ta-p/528727
39
+ var Badgr = oauth2.Endpoint {
40
+ AuthURL : "https://badgr.com/auth/oauth2/authorize" ,
41
+ TokenURL : "https://api.badgr.io/o/token" ,
42
+ }
43
+
20
44
// Battlenet is the endpoint for Battlenet.
21
45
var Battlenet = oauth2.Endpoint {
22
46
AuthURL : "https://battle.net/oauth/authorize" ,
@@ -35,16 +59,44 @@ var Cern = oauth2.Endpoint{
35
59
TokenURL : "https://oauth.web.cern.ch/OAuth/Token" ,
36
60
}
37
61
62
+ // Coinbase is the endpoint for Coinbase.
63
+ //
64
+ // Documentation: https://docs.cdp.coinbase.com/coinbase-app/docs/coinbase-app-reference
65
+ var Coinbase = oauth2.Endpoint {
66
+ AuthURL : "https://login.coinbase.com/oauth2/auth" ,
67
+ TokenURL : "https://login.coinbase.com/oauth2/token" ,
68
+ }
69
+
38
70
// Discord is the endpoint for Discord.
71
+ //
72
+ // Documentation: https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-urls
39
73
var Discord = oauth2.Endpoint {
40
74
AuthURL : "https://discord.com/oauth2/authorize" ,
41
75
TokenURL : "https://discord.com/api/oauth2/token" ,
42
76
}
43
77
78
+ // Dropbox is the endpoint for Dropbox.
79
+ //
80
+ // Documentation: https://developers.dropbox.com/oauth-guide
81
+ var Dropbox = oauth2.Endpoint {
82
+ AuthURL : "https://www.dropbox.com/oauth2/authorize" ,
83
+ TokenURL : "https://api.dropboxapi.com/oauth2/token" ,
84
+ }
85
+
86
+ // Endpoint is Ebay's OAuth 2.0 endpoint.
87
+ //
88
+ // Documentation: https://developer.ebay.com/api-docs/static/authorization_guide_landing.html
89
+ var Endpoint = oauth2.Endpoint {
90
+ AuthURL : "https://auth.ebay.com/oauth2/authorize" ,
91
+ TokenURL : "https://api.ebay.com/identity/v1/oauth2/token" ,
92
+ }
93
+
44
94
// Facebook is the endpoint for Facebook.
95
+ //
96
+ // Documentation: https://developers.facebook.com/docs/facebook-login/guides/advanced/manual-flow
45
97
var Facebook = oauth2.Endpoint {
46
- AuthURL : "https://www.facebook.com/v3.2 /dialog/oauth" ,
47
- TokenURL : "https://graph.facebook.com/v3.2 /oauth/access_token" ,
98
+ AuthURL : "https://www.facebook.com/v22.0 /dialog/oauth" ,
99
+ TokenURL : "https://graph.facebook.com/v22.0 /oauth/access_token" ,
48
100
}
49
101
50
102
// Foursquare is the endpoint for Foursquare.
@@ -104,6 +156,14 @@ var KaKao = oauth2.Endpoint{
104
156
TokenURL : "https://kauth.kakao.com/oauth/token" ,
105
157
}
106
158
159
+ // Line is the endpoint for Line.
160
+ //
161
+ // Documentation: https://developers.line.biz/en/docs/line-login/integrate-line-login/
162
+ var Line = oauth2.Endpoint {
163
+ AuthURL : "https://access.line.me/oauth2/v2.1/authorize" ,
164
+ TokenURL : "https://api.line.me/oauth2/v2.1/token" ,
165
+ }
166
+
107
167
// LinkedIn is the endpoint for LinkedIn.
108
168
var LinkedIn = oauth2.Endpoint {
109
169
AuthURL : "https://www.linkedin.com/oauth/v2/authorization" ,
@@ -140,7 +200,17 @@ var Microsoft = oauth2.Endpoint{
140
200
TokenURL : "https://login.live.com/oauth20_token.srf" ,
141
201
}
142
202
203
+ // Naver is the endpoint for Naver.
204
+ //
205
+ // Documentation: https://developers.naver.com/docs/login/devguide/devguide.md
206
+ var Naver = oauth2.Endpoint {
207
+ AuthURL : "https://nid.naver.com/oauth2/authorize" ,
208
+ TokenURL : "https://nid.naver.com/oauth2/token" ,
209
+ }
210
+
143
211
// NokiaHealth is the endpoint for Nokia Health.
212
+ //
213
+ // Deprecated: Nokia Health is now Withings.
144
214
var NokiaHealth = oauth2.Endpoint {
145
215
AuthURL : "https://account.health.nokia.com/oauth2_user/authorize2" ,
146
216
TokenURL : "https://account.health.nokia.com/oauth2/token" ,
@@ -152,6 +222,14 @@ var Odnoklassniki = oauth2.Endpoint{
152
222
TokenURL : "https://api.odnoklassniki.ru/oauth/token.do" ,
153
223
}
154
224
225
+ // OpenStreetMap is the endpoint for OpenStreetMap.org.
226
+ //
227
+ // Documentation: https://wiki.openstreetmap.org/wiki/OAuth
228
+ var OpenStreetMap = oauth2.Endpoint {
229
+ AuthURL : "https://www.openstreetmap.org/oauth2/authorize" ,
230
+ TokenURL : "https://www.openstreetmap.org/oauth2/token" ,
231
+ }
232
+
155
233
// Patreon is the endpoint for Patreon.
156
234
var Patreon = oauth2.Endpoint {
157
235
AuthURL : "https://www.patreon.com/oauth2/authorize" ,
@@ -170,10 +248,52 @@ var PayPalSandbox = oauth2.Endpoint{
170
248
TokenURL : "https://api.sandbox.paypal.com/v1/identity/openidconnect/tokenservice" ,
171
249
}
172
250
251
+ // Pinterest is the endpoint for Pinterest.
252
+ //
253
+ // Documentation: https://developers.pinterest.com/docs/getting-started/set-up-authentication-and-authorization/
254
+ var Pinterest = oauth2.Endpoint {
255
+ AuthURL : "https://www.pinterest.com/oauth" ,
256
+ TokenURL : "https://api.pinterest.com/v5/oauth/token" ,
257
+ }
258
+
259
+ // Pipedrive is the endpoint for Pipedrive.
260
+ //
261
+ // Documentation: https://developers.pipedrive.com/docs/api/v1/Oauth
262
+ var Pipedrive = oauth2.Endpoint {
263
+ AuthURL : "https://oauth.pipedrive.com/oauth/authorize" ,
264
+ TokenURL : "https://oauth.pipedrive.com/oauth/token" ,
265
+ }
266
+
267
+ // QQ is the endpoint for QQ.
268
+ //
269
+ // Documentation: https://wiki.connect.qq.com/%e5%bc%80%e5%8f%91%e6%94%bb%e7%95%a5_server-side
270
+ var QQ = oauth2.Endpoint {
271
+ AuthURL : "https://graph.qq.com/oauth2.0/authorize" ,
272
+ TokenURL : "https://graph.qq.com/oauth2.0/token" ,
273
+ }
274
+
275
+ // Rakuten is the endpoint for Rakuten.
276
+ //
277
+ // Documentation: https://webservice.rakuten.co.jp/documentation
278
+ var Rakuten = oauth2.Endpoint {
279
+ AuthURL : "https://app.rakuten.co.jp/services/authorize" ,
280
+ TokenURL : "https://app.rakuten.co.jp/services/token" ,
281
+ }
282
+
173
283
// Slack is the endpoint for Slack.
284
+ //
285
+ // Documentation: https://api.slack.com/authentication/oauth-v2
174
286
var Slack = oauth2.Endpoint {
175
- AuthURL : "https://slack.com/oauth/authorize" ,
176
- TokenURL : "https://slack.com/api/oauth.access" ,
287
+ AuthURL : "https://slack.com/oauth/v2/authorize" ,
288
+ TokenURL : "https://slack.com/api/oauth.v2.access" ,
289
+ }
290
+
291
+ // Splitwise is the endpoint for Splitwise.
292
+ //
293
+ // Documentation: https://dev.splitwise.com/
294
+ var Splitwise = oauth2.Endpoint {
295
+ AuthURL : "https://www.splitwise.com/oauth/authorize" ,
296
+ TokenURL : "https://www.splitwise.com/oauth/token" ,
177
297
}
178
298
179
299
// Spotify is the endpoint for Spotify.
@@ -212,6 +332,22 @@ var Vk = oauth2.Endpoint{
212
332
TokenURL : "https://oauth.vk.com/access_token" ,
213
333
}
214
334
335
+ // Withings is the endpoint for Withings.
336
+ //
337
+ // Documentation: https://account.withings.com/oauth2_user/authorize2
338
+ var Withings = oauth2.Endpoint {
339
+ AuthURL : "https://account.withings.com/oauth2_user/authorize2" ,
340
+ TokenURL : "https://account.withings.com/oauth2/token" ,
341
+ }
342
+
343
+ // X is the endpoint for X (Twitter).
344
+ //
345
+ // Documentation: https://docs.x.com/resources/fundamentals/authentication/oauth-2-0/user-access-token
346
+ var X = oauth2.Endpoint {
347
+ AuthURL : "https://x.com/i/oauth2/authorize" ,
348
+ TokenURL : "https://api.x.com/2/oauth2/token" ,
349
+ }
350
+
215
351
// Yahoo is the endpoint for Yahoo.
216
352
var Yahoo = oauth2.Endpoint {
217
353
AuthURL : "https://api.login.yahoo.com/oauth2/request_auth" ,
@@ -230,6 +366,20 @@ var Zoom = oauth2.Endpoint{
230
366
TokenURL : "https://zoom.us/oauth/token" ,
231
367
}
232
368
369
+ // Asgardeo returns a new oauth2.Endpoint for the given tenant.
370
+ //
371
+ // Documentation: https://wso2.com/asgardeo/docs/guides/authentication/oidc/discover-oidc-configs/
372
+ func AsgardeoEndpoint (tenant string ) oauth2.Endpoint {
373
+ u := url.URL {
374
+ Scheme : "https" ,
375
+ Host : "api.asgardeo.io" ,
376
+ }
377
+ return oauth2.Endpoint {
378
+ AuthURL : u .JoinPath ("t" , tenant , "/oauth2/authorize" ).String (),
379
+ TokenURL : u .JoinPath ("t" , tenant , "/oauth2/token" ).String (),
380
+ }
381
+ }
382
+
233
383
// AzureAD returns a new oauth2.Endpoint for the given tenant at Azure Active Directory.
234
384
// If tenant is empty, it uses the tenant called `common`.
235
385
//
@@ -239,19 +389,29 @@ func AzureAD(tenant string) oauth2.Endpoint {
239
389
if tenant == "" {
240
390
tenant = "common"
241
391
}
392
+ u := url.URL {
393
+ Scheme : "https" ,
394
+ Host : "login.microsoftonline.com" ,
395
+ }
242
396
return oauth2.Endpoint {
243
- AuthURL : "https://login.microsoftonline.com/" + tenant + "/oauth2/v2.0/authorize" ,
244
- TokenURL : "https://login.microsoftonline.com/" + tenant + "/oauth2/v2.0/token" ,
245
- DeviceAuthURL : "https://login.microsoftonline.com/" + tenant + "/oauth2/v2.0/devicecode" ,
397
+ AuthURL : u . JoinPath ( tenant , "/oauth2/v2.0/authorize" ). String () ,
398
+ TokenURL : u . JoinPath ( tenant , "/oauth2/v2.0/token" ). String () ,
399
+ DeviceAuthURL : u . JoinPath ( tenant , "/oauth2/v2.0/devicecode" ). String () ,
246
400
}
247
401
}
248
402
249
- // HipChatServer returns a new oauth2.Endpoint for a HipChat Server instance
250
- // running on the given domain or host.
251
- func HipChatServer (host string ) oauth2.Endpoint {
403
+ // AzureADB2CEndpoint returns a new oauth2.Endpoint for the given tenant and policy at Azure Active Directory B2C.
404
+ // policy is the Azure B2C User flow name Example: `B2C_1_SignUpSignIn`.
405
+ //
406
+ // Documentation: https://docs.microsoft.com/en-us/azure/active-directory-b2c/tokens-overview#endpoints
407
+ func AzureADB2CEndpoint (tenant string , policy string ) oauth2.Endpoint {
408
+ u := url.URL {
409
+ Scheme : "https" ,
410
+ Host : tenant + ".b2clogin.com" ,
411
+ }
252
412
return oauth2.Endpoint {
253
- AuthURL : "https://" + host + "/users/ authorize" ,
254
- TokenURL : "https://" + host + "/v2/oauth/ token" ,
413
+ AuthURL : u . JoinPath ( tenant + ".onmicrosoft.com" , policy , "/oauth2/v2.0/ authorize"). String () ,
414
+ TokenURL : u . JoinPath ( tenant + ".onmicrosoft.com" , policy , "/oauth2/v2.0/ token"). String () ,
255
415
}
256
416
}
257
417
@@ -264,9 +424,42 @@ func HipChatServer(host string) oauth2.Endpoint {
264
424
// https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-assign-domain.html
265
425
// https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-userpools-server-contract-reference.html
266
426
func AWSCognito (domain string ) oauth2.Endpoint {
267
- domain = strings .TrimRight (domain , "/" )
427
+ u , err := url .Parse (domain )
428
+ if err != nil || u .Scheme == "" || u .Host == "" {
429
+ panic ("endpoints: invalid domain" + domain )
430
+ }
431
+ return oauth2.Endpoint {
432
+ AuthURL : u .JoinPath ("/oauth2/authorize" ).String (),
433
+ TokenURL : u .JoinPath ("/oauth2/token" ).String (),
434
+ }
435
+ }
436
+
437
+ // HipChatServer returns a new oauth2.Endpoint for a HipChat Server instance.
438
+ // host should be a hostname, without any scheme prefix.
439
+ //
440
+ // Documentation: https://developer.atlassian.com/server/hipchat/hipchat-rest-api-access-tokens/
441
+ func HipChatServer (host string ) oauth2.Endpoint {
442
+ u := url.URL {
443
+ Scheme : "https" ,
444
+ Host : host ,
445
+ }
446
+ return oauth2.Endpoint {
447
+ AuthURL : u .JoinPath ("/users/authorize" ).String (),
448
+ TokenURL : u .JoinPath ("/v2/oauth/token" ).String (),
449
+ }
450
+ }
451
+
452
+ // Shopify returns a new oauth2.Endpoint for the supplied shop domain name.
453
+ // host should be a hostname, without any scheme prefix.
454
+ //
455
+ // Documentation: https://shopify.dev/docs/apps/auth/oauth
456
+ func Shopify (host string ) oauth2.Endpoint {
457
+ u := url.URL {
458
+ Scheme : "https" ,
459
+ Host : host ,
460
+ }
268
461
return oauth2.Endpoint {
269
- AuthURL : domain + "/oauth2/ authorize" ,
270
- TokenURL : domain + "/oauth2/token" ,
462
+ AuthURL : u . JoinPath ( "/admin/oauth/ authorize"). String () ,
463
+ TokenURL : u . JoinPath ( "/admin/oauth/access_token" ). String () ,
271
464
}
272
465
}
0 commit comments