SHARE
TWEET

Untitled

a guest May 23rd, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const express = require("express");
  2. const app = express();
  3. const dotenv = require("dotenv").config();
  4. const spotify = require("./credentials");
  5. const bodyParser = require("body-parser");
  6. const cors = require("cors");
  7. const querystring = require('querystring');
  8.  
  9. const authorizeSpotify = require("./authorizeSpotify");
  10. const getAccessToken = require("./getAccessToken");
  11.  
  12. app.use(cors());
  13. app.use(bodyParser.json());
  14. app.use(bodyParser.urlencoded({ extended: true }));
  15.  
  16. app.get("/auth", authorizeSpotify);
  17. app.get("/callback", getAccessToken, (req, res, next) => {
  18.  
  19.     res.redirect(
  20.         `${process.env.CLIENT_URL}/` +
  21.             querystring.stringify({
  22.                 access_token: req.credentials.access_token,
  23.                 refresh_token: req.credentials.refresh_token
  24.             })
  25.     );
  26. });
  27.  
  28. app.set("port", process.env.PORT || 8888);
  29. const server = app.listen(app.get("port"), () => {
  30.     console.log(`Starting server on ${server.address().port}`);
  31. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top