Created
August 19, 2016 17:48
-
-
Save brandonaaskov/71cd4cee7e345d39d6d9b0017b8fbba4 to your computer and use it in GitHub Desktop.
Basic OAuth Example for Linking Accounts with an Alexa Skill
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
var express = require('express') | |
var router = express.Router() | |
var qs = require('qs') | |
function login (req, res) { | |
const query = qs.parse(req.query) | |
req.session.alexa = query // store the variables for the redirect URI after successful login | |
res.render('login') | |
} | |
function getRequestToken (req, res) { | |
const token = '1234567890abcdefghij' // super secure token | |
const alexa = req.session.alexa | |
const url = `${alexa.redirect_uri}#access_token=${token}&state=${alexa.state}&token_type=bearer` | |
res.redirect(url) | |
} | |
router.get('/login', login) | |
router.post('/oauth/authorize', getRequestToken) | |
module.exports = router |
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
extends layout | |
block content | |
form(id='login', method='post', action='/oauth/authorize') | |
.form-group | |
label Username | |
input.form-control(type='text', name='username') | |
.form-group | |
label Password | |
input.form-control(type='password', name='password') | |
button(type='submit') Submit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment