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

@mozeyinedu/oauth

v0.0.33

Published

## Social Media Login

Downloads

381

Readme

oauth

Social Media Login

Installation

npm i @mozeyinedu/oauth

Usage

    const Oauth = require('@mozeyinedu/oauth).default;
    const oauth = new Oauth()

    // OR

    import Oauth from '@mozeyinedu/oauth';
    const oauth = new Oauth()

Google

Set up your consent screen and client_id and client_secret on google development console

Front End
    // open consent screen and get code
    const googleLogin = () => {
        oauth.google.open_consent_screen({
            client_id: process.env.NEXT_PUBLIC_CLIENT_ID
            redirect_uri: process.env.NEXT_PUBLIC_REDIRECT_URI
        })
    }
    // call this function googleLogin on a click of a button (Login with google)
    // From the consent screen, you will be redirected to a page that you added on google
    // get the code from url query string
    // send the code to the back
Back End
    // retrieve the code sent from the client
    // use the code and get accesstoken

    // get accesstoken
    const accesstoken = await oauth.google.get_accesstoken({
        code,
        client_id: process.env.CLIENT_ID,
        client_secret: process.env.CLIENT_SECRET
        redirect_uri: process.env.FRONT_END_REDIRECT_URI // this must have been added on google development console as described above
    })

    // get user data using the accesstoken
    const data = await oauth.google.get_user({ accesstoken })
    console.log( data )

    // get user data straight up
    const userData = await oauth.google.get_user2({
        code,
        client_id: process.env.CLIENT_ID,
        client_secret: process.env.CLIENT_SECRET
        redirect_uri: process.env.FRONT_END_REDIRECT_URI // this must have been added on google development console as described above
    }) 
    console.log(data)

Github

Set up your consent screen and client_id and client_secret on github developer settings

Front End
    // open consent screen and get code
    const githubLogin = () => {
        oauth.github.open_consent_screen({
            client_id: process.env.NEXT_PUBLIC_CLIENT_ID,
        })
    }
    // call this function githubLogin on a click of a button (Login with github)
    // From the consent screen, you will be redirected to a page that you added on github
    // get the code from url query string
    // send the code to the back
Back End
    // retrieve the code sent from the client
    // use the code and get accesstoken

    // get accesstoken
    const accesstoken = await oauth.github.get_accesstoken({
        code,
        client_id: process.env.CLIENT_ID,
        client_secret: process.env.CLIENT_SECRET
    })

    // get user data using the accesstoken
    const data = await oauth.github.get_user({ accesstoken })
    console.log( data );

    // get user data straight up
    const userData = await oauth.github.get_user2({
        code,
        client_id: process.env.CLIENT_ID,
        client_secret: process.env.CLIENT_SECRET
        redirect_uri: process.env.FRONT_END_REDIRECT_URI // this must have been added on github developer settings as described above
    }) 
    console.log(data)

Facebook

Set up your consent screen and client_id and client_secret on meta for developers

Front End
    // open consent screen and get code
    const facebookLogin = () => {
        oauth.facebook.open_consent_screen({
            client_id: process.env.NEXT_PUBLIC_CLIENT_ID,
        })
    }
    // call this function facebookLogin on a click of a button (Login with facebook)
    // From the consent screen, you will be redirected to a page that you added on facebook
    // get the code from url query string
    // send the code to the back
Back End
    // retrieve the code sent from the client
    // use the code and get accesstoken

    // get accesstoken
    const accesstoken = await oauth.facebook.get_accesstoken({
        code,
        client_id: process.env.CLIENT_ID,
        client_secret: process.env.CLIENT_SECRET
    })

    // get user data using the accesstoken
    const data = await oauth.facebook.get_user({ accesstoken })
    console.log( data );

    // get user data straight up
    const userData = await oauth.facebook.get_user2({
        code,
        client_id: process.env.CLIENT_ID,
        client_secret: process.env.CLIENT_SECRET
        redirect_uri: process.env.FRONT_END_REDIRECT_URI // this must have been added on meta for developers as described above
    }) 
    console.log(data)

Twitter

Set up your consent screen and client_id and client_secret on Twitter Developer Portal

Front End
    // open consent screen and get code
    const twitterLogin = () => {
        oauth.twitter.open_consent_screen({
            client_id: process.env.NEXT_PUBLIC_CLIENT_ID,
        })
    }
    // call this function twitterLogin on a click of a button (Login with Twitter)
    // From the consent screen, you will be redirected to a page that you added on Twitter
    // get the code from url query string
    // send the code to the back
Back End
    // retrieve the code sent from the client
    // use the code and get accesstoken

    // get accesstoken
    const accesstoken = await oauth.twitter.get_accesstoken({
        code,
        client_id: process.env.CLIENT_ID,
        client_secret: process.env.CLIENT_SECRET
    })

    // get user data using the accesstoken
    const data = await oauth.twitter.get_user({ accesstoken })
    console.log( data );

    // get user data straight up
    const userData = await oauth.twitter.get_user2({
        code,
        client_id: process.env.CLIENT_ID,
        client_secret: process.env.CLIENT_SECRET
        redirect_uri: process.env.FRONT_END_REDIRECT_URI // this must have been added on Twitter Developer Portal as described above
    }) 
    console.log(data)

Instagram

Apple

Tiktok

Microsoft