npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

twiz_oauth2

v1.0.1

Published

Twiz_oauth2 is a custom OAuth2 authentication and authorization system meticulously designed for Twiz.lol. It enables users to securely authorize third-party applications to access their Twiz.lol data, fostering a seamless and controlled sharing of inform

Downloads

2

Readme

What is twiz_oauth2?

Twiz_oauth2 is a custom OAuth2 authentication and authorization system meticulously designed for Twiz.lol. It enables users to securely authorize third-party applications to access their Twiz.lol data, fostering a seamless and controlled sharing of information. With Twiz_oauth2, users can conveniently authenticate their accounts on external platforms while maintaining control over the data they choose to share. This system prioritizes security and user control, empowering individuals to manage their data privacy across connected applications.

How to use?

For now it only supports nodejs expressjs the py and flask still undergoing develoment

Using Twiz_oauth2 with Node.js and Express.js

1. Install Dependencies

npm install twiz_oauth2

OR

npm i @sentiax/twiz_oauth2

2. Configuration

Set up the required configurations in your Express.js application. This might include client IDs, secrets, redirect URIs, etc., provided by the Twiz.lol OAuth2 system.

3. Implementation

Once configured, you can integrate the OAuth2 flow within your Express.js routes:

1. Initiate OAuth2 Flow && Example

const express = require('express');

const app = express();
const port = 3001;

const session = require('express-session');
app.use(session({
  secret: '1313131412141241412412412', // Replace with your own secret key
  resave: false,
  saveUninitialized: true
}));
const twiz_oauth2 = require('twiz_oauth2');

// Initialize Twiz_oauth2
twiz_oauth2.init({
  clientID: '',
  redirection: '/close_popup',
});
if (twiz_oauth2.url == null) return console.error('ClientId not vaild')
// Redirect users to Twiz.lol authorization page
app.get("/login", (req, res) => {
  res.redirect(`${twiz_oauth2.url()}`)
});

// The after callback function
app.get('/close_popup', (req, res) => {
  res.send("closing...<script>window.close();  window.opener.location.reload();</script>")
})


// logout
app.get('/logout',(req,res)=> {
  req.session.destroy();
  res.redirect("/");
})

// callback
app.get('/reversed_pro', twiz_oauth2.callback);

// For realtime data access
app.get("/", async(req,res)=> {
  // console.log(req.session);
  let user = req.session.user ? req.session.user.twiz.email : null;
  if (!user) {
    res.render("index.ejs", {
      user: user,
      code: twiz_oauth2.user_code(req),
    })
  } else {
  const data = await twiz_oauth2.update_user_data(req, res);
  await console.log(data);
  if (await data == "success") {
  // console.log(req.session.user);
  res.render("index.ejs",  {
    user: user,
    code: twiz_oauth2.user_code(req),
  })
} else {
  // Access may be revoked or data couldn't be updated  
  res.status(404).json("Access revoked");
}
  }
})
// For non realtime data
// app.get("/", async (req, res) => {
//   let user = req.session.user ? req.session.user.twiz.email : null;
//   res.render("index.ejs",  {
//         user: user,
//         code: twiz_oauth2.user_code(req),
//       })
// })

app.listen(port, () => {
  console.log(`Server is running on http://localhost:${port}`);
});