Skip to content

Commit 5984fc7

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

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

src/modules/line.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
// WRAPPER
24+
get: {
25+
me: function (p, callback) {
26+
p.path = "https://api.line.me/v2/profile";
27+
p.headers = {
28+
Authorization: `Bearer ${p.authResponse.access_token}`,
29+
};
30+
callback("https://api.line.me/v2/profile");
31+
},
32+
},
33+
34+
login: function (p) {
35+
// OAuth2 non-standard adjustments
36+
p.qs.scope = "profile%20openid%20email";
37+
},
38+
39+
wrap: {
40+
me: function (o) {
41+
if (o.userId) {
42+
o.picture = o.thumbnail = o.pictureUrl;
43+
o.id = o.userId;
44+
o.name = o.displayName;
45+
}
46+
47+
return o;
48+
},
49+
},
50+
51+
jsonp: false,
52+
},
53+
});
54+
})(hello);

0 commit comments

Comments
 (0)