Created
October 20, 2019 19:40
-
-
Save PamornT/dba38052e8a453a506b880fc394e8300 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const issue_access_token = async() => { | |
let params = { | |
grant_type: 'client_credentials', | |
client_id: CHANNEL_ID, | |
client_secret: CHANNEL_SECRET | |
}; | |
let formData = querystring.stringify(params); | |
let contentLength = formData.length; | |
let promise = new Promise(resolve => { | |
request.post({ | |
url: `${LINE_OAUTH_API}/accessToken`, | |
headers: { | |
'Content-Length': contentLength, | |
'Content-Type': 'application/x-www-form-urlencoded' | |
}, | |
body: formData | |
}, (error, response, body) => { | |
if(!error) | |
resolve(body); | |
else | |
resolve(error); | |
}) | |
}); | |
let result = await promise; | |
return result; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment