2.0.0 • Published 3 years ago

tm.js v2.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

tm Token Manager

Using OAuth in your project, presents token and other OAuth stuff. local

Discord

Import

Import the api connection with the dependencies in the package.json file

"dependencies": {
    "tm.js": "^1.1.8"
  }

The next step is to download/install it with the npm command

npm install

after that you can start coding with

const tm = require("tm.js");

in you're js file.

How to run

Now you can use tm.authorize to start a local authorization:

tm.authorize("api url with endpoint", "your client_id", "your scopes")
  .then((message) => {
    //message is the code, but you can access the code also with:
    var auth_code = tm.getAuthorizeCode();
  })
  .catch((err) => {
    // in case of error
    console.log( err );
  });

after the authorization you can access the token with:

tm.token("api url with endpoint", "your client_id", "your client_secret")
        .then((message) => {
            //message is the code, but you can access the token also with:
            var access_token = tm.getAccessToken();
        }).catch((err) => {
            // in case of error
            console.debug(err);
    });

after these steps your done!

Await / .then

You can choice between await or .then. Here are both ways to look at: AWAIT

async function f() {
    await tm.authorize("api url with endpoint", "your client_id", "scopes")

    console.debug(tm.getAuthorizeCode());

    await tm.token("api url with endpoint", "your client_id", "your client_secret");
    
    console.debug(tm.getAccessToken());
}

or with .THEN

tm.authorize("api url with endpoint", "your client_id", "scopes")
    .then((message) => {
        tm.token("api url with endpoint", "your client_id", "your client_secret")
            .then((message) => {
                console.debug(message)
            });
    })
    .catch((err) => {
        console.debug(err)
    })

All api functions

tm.getAccessToken()
tm.getAuthorizeCode()
tm.getExpiresIn()
tm.getRefreshToken()
tm.getScope()
tm.getTokenType()

tm.authorize()
tm.token()
tm.token_refresh()
2.0.0

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago