Skip to content

Commit

Permalink
feat: add line login modules
Browse files Browse the repository at this point in the history
  • Loading branch information
h4i4nhnc committed Dec 16, 2021
1 parent db93ed7 commit 5984fc7
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/modules/line.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
(function (hello) {

hello.init({
line: {
name: "line",
oauth: {
version: 2,
auth: "https://access.line.me/oauth2/v2.1/authorize",
grant: "https://api.line.me/oauth2/v2.1/token",
response_type: "code",
client_secret: process.env.LINE_CLIENT_SECRET,
scope: {
basic: "profile%20openid%20email", // https://developers.line.biz/en/docs/line-login/integrate-line-login/#scopes
},
state: Math.random(),
scope_map: {
basic: ["profile", "openid", "email"],
},
},

base: "https://access.line.me/oauth2/v2.1/",

// WRAPPER
get: {
me: function (p, callback) {
p.path = "https://api.line.me/v2/profile";
p.headers = {
Authorization: `Bearer ${p.authResponse.access_token}`,
};
callback("https://api.line.me/v2/profile");
},
},

login: function (p) {
// OAuth2 non-standard adjustments
p.qs.scope = "profile%20openid%20email";
},

wrap: {
me: function (o) {
if (o.userId) {
o.picture = o.thumbnail = o.pictureUrl;
o.id = o.userId;
o.name = o.displayName;
}

return o;
},
},

jsonp: false,
},
});
})(hello);

0 comments on commit 5984fc7

Please sign in to comment.