-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoauthConfig.ts
69 lines (64 loc) · 1.84 KB
/
oauthConfig.ts
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
import clientConfig from "./clientConfig"
type Config = {
name: string
url: string
authorizationEndpoint: string
clientId: string
redirectUrl: string
requiredUrlParams: Array<Array<string>>
scopes: Array<string>
scopeDelimiter: string
optionalUrlParams?: Array<Array<string>>
popupOptions: {
width: number
height: number
}
}
type Auth = {
google: Config
linkedin: Config
orcid: Config
[index: string]: any
}
const basename = process.env.NEXT_PUBLIC_BASENAME
const url = typeof window !== "undefined" ? window.location.origin : ""
const oauthConfig: Auth = {
google: {
name: "Google",
url: "/auth/google",
authorizationEndpoint: "https://accounts.google.com/o/oauth2/v2/auth",
clientId: clientConfig.google.clientId,
redirectUrl: `${url}/${basename}/google/callback`,
requiredUrlParams: [["response_type", "code"]],
scopes: ["email"],
scopeDelimiter: " ",
optionalUrlParams: [["state", "google"]],
popupOptions: { width: 1020, height: 633 },
},
linkedin: {
name: "LinkedIn",
url: "/auth/linkedin",
authorizationEndpoint: "https://www.linkedin.com/oauth/v2/authorization",
clientId: clientConfig.linkedin.clientId,
redirectUrl: `${url}/${basename}/linkedin/callback`,
scopes: ["r_emailaddress"],
scopeDelimiter: " ",
requiredUrlParams: [
["state", "linkedin"],
["response_type", "code"],
],
popupOptions: { width: 1028, height: 640 },
},
orcid: {
name: "ORCID",
url: "/auth/orcid",
authorizationEndpoint: "https://orcid.org/oauth/authorize",
clientId: clientConfig.orcid.clientId,
redirectUrl: `${url}/${basename}/orcid/callback`,
scopes: ["/authenticate"],
scopeDelimiter: " ",
requiredUrlParams: [["response_type", "code"]],
popupOptions: { width: 1028, height: 640 },
},
}
export default oauthConfig