Advertisement
Guest User

Untitled

a guest
Apr 1st, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. const axios = require('axios');
  2.  
  3. module.exports.main = async (event) => {
  4. const { code } = event.queryStringParameters;
  5. let accessToken = null;
  6. await axios({
  7. method: 'post',
  8. url: `https://login.eveonline.com/oauth/token?grant_type=authorization_code&code=${code}`,
  9. auth: {
  10. username: process.env.CLIENT_ID,
  11. password: process.env.CLIENT_SECRET,
  12. },
  13. headers: {
  14. accept: 'application/json',
  15. },
  16. }).then((response) => {
  17. accessToken = response.data.access_token;
  18. });
  19. return {
  20. statusCode: 301,
  21. body: JSON.stringify({ result: 'ok' }),
  22. headers: {
  23. 'Access-Control-Allow-Origin': '*',
  24. 'Access-Control-Allow-Credentials': true,
  25. Location: 'https://dgwxfhbva6lnp.cloudfront.net',
  26. 'Set-Cookie': `evi-auth-token=${accessToken}; Secure; Domain=dgwxfhbva6lnp.cloudfront.net; HttpOnly`,
  27. },
  28. };
  29. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement