tweak auth storage location
This commit is contained in:
parent
dc891451d9
commit
6ffd098a74
1 changed files with 8 additions and 6 deletions
14
lib/auth.js
14
lib/auth.js
|
|
@ -1,5 +1,7 @@
|
|||
var inquirer = require('inquirer'),
|
||||
dotenv = require('dotenv').load(),
|
||||
path = require('path'),
|
||||
config = path.join(process.env['HOME'], '.npr-one'),
|
||||
dotenv = require('dotenv').load({silent: true, path: config}),
|
||||
fs = require('fs'),
|
||||
npr;
|
||||
|
||||
|
|
@ -7,12 +9,12 @@ var client_creds = [
|
|||
{
|
||||
type: 'input',
|
||||
name: 'CLIENT_ID',
|
||||
message: 'NPR OAuth Client ID',
|
||||
message: 'NPR Application ID',
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'CLIENT_SECRET',
|
||||
message: 'NPR OAuth Client Secret',
|
||||
message: 'NPR Application Secret',
|
||||
}
|
||||
];
|
||||
|
||||
|
|
@ -20,7 +22,7 @@ var device_code = [
|
|||
{
|
||||
type: 'list',
|
||||
name: 'device',
|
||||
message: 'Authorize this Pi @ ',
|
||||
message: 'Authorize the NPR One CLI @ ',
|
||||
choices: ['Complete', 'Exit']
|
||||
}
|
||||
];
|
||||
|
|
@ -33,7 +35,7 @@ var requestDeviceCode = function() {
|
|||
.generateDeviceCode({
|
||||
client_id: process.env.CLIENT_ID,
|
||||
client_secret: process.env.CLIENT_SECRET,
|
||||
scope: 'listening.write identity.readonly'
|
||||
scope: 'listening.readonly listening.write identity.readonly'
|
||||
})
|
||||
.then(function(res) {
|
||||
|
||||
|
|
@ -110,7 +112,7 @@ exports.getToken = function(api) {
|
|||
.then(requestDeviceCode.bind(this))
|
||||
.then(requestToken.bind(this))
|
||||
.then(function(token) {
|
||||
fs.writeFileSync('.env', 'NPR_ACCESS_TOKEN=' + process.env.NPR_ACCESS_TOKEN + '\n');
|
||||
fs.writeFileSync(config, 'NPR_ACCESS_TOKEN=' + process.env.NPR_ACCESS_TOKEN + '\n');
|
||||
resolve(token);
|
||||
})
|
||||
.catch(reject);
|
||||
|
|
|
|||
Loading…
Reference in a new issue