Skip to content

Commit

Permalink
fix payload and add sample
Browse files Browse the repository at this point in the history
  • Loading branch information
jupe committed Oct 20, 2018
1 parent 541679b commit a9e43f8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions sample/login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const {Authentication, Transport} = require('../src');

const transport = new Transport('http://localhost:3000');
const auth = new Authentication(transport);
auth.loginWithToken(process.env.GITHUB_ACCESS_TOKEN)
.then(() => {
console.log('login success');
})
.catch((error) => {
console.error(`login fails: ${error}`);
})
2 changes: 1 addition & 1 deletion src/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Authentication {
invariant(_.isString(token), 'token should be string');
invariant(_.isString(service), 'service should be string');
return this._transport
.post(`/auth/${service}/token`, {token}, {})
.post(`/auth/${service}/token`, {access_token: token}, {}) // eslint-disable-line camelcase
.then((response) => {
invariant(response.data.token, 'there should be token');
debug(`Login response: ${JSON.stringify(response.data)}`);
Expand Down

0 comments on commit a9e43f8

Please sign in to comment.