Created
          August 15, 2019 03:51 
        
      - 
      
 - 
        
Save PrimeTimeTran/66bad1e9c9cbdcbe466ca10f97df70b2 to your computer and use it in GitHub Desktop.  
  
    
      This file contains hidden or 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 http = require('http'); | |
| const request = require('request'); | |
| require('dotenv').config(); | |
| const clientId = process.env.REACT_APP_CLIENT_ID; | |
| const secretKey = process.env.REACT_APP_SECRET_KEY; | |
| console.log('started server on port 5000'); | |
| http.createServer((req, res) => { | |
| var code = req.url.split("=")[1]; | |
| if (code) { | |
| request.post('https://github.com/login/oauth/access_token', { | |
| form: { | |
| client_id: clientId, | |
| client_secret: secretKey, | |
| code: code | |
| } | |
| }, (err, r, body) => { | |
| res.writeHead(301, { | |
| 'Location': 'http://localhost:3000?' + body | |
| }); | |
| res.end(); | |
| }) | |
| } else { | |
| res.writeHead(404); | |
| res.end(); | |
| } | |
| }).listen(5000); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment