Skip to content

Commit d575901

Browse files
committed
feat: add line login modules
1 parent db93ed7 commit d575901

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

src/modules/line.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
(function (hello) {
2+
3+
hello.init({
4+
line: {
5+
name: "line",
6+
oauth: {
7+
version: 2,
8+
auth: "https://access.line.me/oauth2/v2.1/authorize",
9+
grant: "https://api.line.me/oauth2/v2.1/token",
10+
response_type: "code",
11+
client_secret: process.env.LINE_CLIENT_SECRET,
12+
scope: {
13+
basic: "profile%20openid%20email", // https://developers.line.biz/en/docs/line-login/integrate-line-login/#scopes
14+
},
15+
state: Math.random(),
16+
scope_map: {
17+
basic: ["profile", "openid", "email"],
18+
},
19+
},
20+
21+
base: "https://access.line.me/oauth2/v2.1/",
22+
23+
get: {
24+
me: function (p, callback) {
25+
p.path = "https://api.line.me/v2/profile";
26+
p.headers = {
27+
Authorization: `Bearer ${p.authResponse.access_token}`,
28+
};
29+
callback("https://api.line.me/v2/profile");
30+
},
31+
},
32+
33+
login: function (p) {
34+
// OAuth2 non-standard adjustments
35+
p.qs.scope = "profile%20openid%20email";
36+
},
37+
38+
wrap: {
39+
me: function (o) {
40+
if (o.userId) {
41+
o.picture = o.thumbnail = o.pictureUrl;
42+
o.id = o.userId;
43+
o.name = o.displayName;
44+
}
45+
46+
return o;
47+
},
48+
},
49+
50+
jsonp: false,
51+
},
52+
});
53+
})(hello);

0 commit comments

Comments
 (0)