mastodon-get-token

0.0.1 • Public • Published

Do the oauth dance to get a user's access token, knowing the password.

This is meant for bots, where the machine is going to know the password.

If you're dealing with an end user, you'll need to open a browser and do this properly. You don't want to be handling their password, and they might be using 2FA anyway.

Command line usage

Use mastodon-register-app and mastodon-create-account first, in the same directory, giving you an app-registration.json and user-details-USERNAME.json files, which have data we need to get the tokens.

$ npm install -g mastodon-get-token
$ mastodon-get-token test7
wrote access-token-test7.json
$ cat access-token-test7.json
{
   ...
}

Library usage

$ npm install --save mastodon-get-token
const getToken = require('mastodon-get-token')
 
const appreg = require('./app-registration.json')
const user = require('./user-details-alice.json')
 
getToken(appreg, user)
  .then(access => {
     // use access.server and access.token is what you'll need for the API
  })

Package Sidebar

Install

npm i mastodon-get-token

Weekly Downloads

1

Version

0.0.1

License

MIT

Last publish

Collaborators

  • sandhawke