@mixer/shortcode-oauth
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

@mixer/shortcode-auth

npm install --save @mixer/shortcode-oauth

This is a client for Mixer shortcode OAuth in Node.js. An example can be found in example.js in this directory. For more information about OAuth in general, check out the OAuth reference page on the Mixer developer site.

const { ShortCodeExpireError, OAuthClient } = require('@mixer/shortcode-oauth');

const client = new OAuthClient({
  clientId: '<Your OAuth token here!>',
  scopes: ['interactive:robot:self'],
});

const attempt = () =>
  client
    .getCode()
    .then(code => {
      console.log(`Go to mixer.com/go and enter ${code.code}`);
      return code.waitForAccept();
    })
    .catch(err => {
      if (err instanceof ShortCodeExpireError) {
        return attempt(); // loop!
      }

      throw err;
    });

attempt().then(tokens => console.log(`Token data`, tokens.data));

Example:

Go to mixer.com/go and enter E2LM8U
Token data { accessToken: '<snip>',
  refreshToken: '<snip>',
  expiresAt: 2018-08-23T06:56:49.169Z,
  scopes: [ 'interactive:robot:self' ] }

Package Sidebar

Install

npm i @mixer/shortcode-oauth

Weekly Downloads

144

Version

1.2.0

License

MIT

Unpacked Size

39.7 kB

Total Files

20

Last publish

Collaborators

  • jamy
  • probableprime
  • deeky
  • aechdub
  • connor.peet