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

twitter-login-client

v1.0.3

Published

Implements a Client-Side flow for login with twitter, similar to one provided by Facebook and Google. To read the Flow of implementing Login with Twitter.

Downloads

58

Readme

Javascript Client for Login with Twitter

NPM Version NPM Downloads Bower version GitHub issues GitHub forks GitHub license

Implements a Client-Side flow for login with twitter, similar to one provided by Facebook and Google. To read the Flow of implementing Login with Twitter, Read here

Installation:

  • Clone as a Git repository
    git clone https://github.com/mdemblani/twitter-login-client.git
  • Install as a node_module
    npm i twitter-login-client --save
    
    OR
    
    npm install twitter-login-client --save
  • Install as Bower Component
    bower install <package> --save

Getting Started:

  1. To Include the Script, add the following:

        <script src="link to twitter-client code"></script>
  2. The following snippet is used to initalize the twitter-client library

        window.twitterInit =  = function () {
            twttr.init({
                api_key: 'TWITTER_CLIENT_ID',
                request_url: 'REQUEST-TOKEN-ENDPOINT'
            });
        };
    • api_key: Your twitter consumer id

    • request_url: This is an endpoint in your application, that twitter-client.js would call, to receive a request_token that your application generated when communicating with twitter. The twitter-client depends on the response it receives from the application for request_token. This endpoint should implement STEP 1 in Login with Twitter. The response should have the following: - success: [Boolean] : True on Success, False on Failure - oauth_token: [String] : REQUEST_TOKEN received from twitter - message: [String] : If success is False, then contains a error message indicating the error, ignored when success is true.

      Note: The following tokens are mutually exclusive a. message b. oauth_token

  3. Create a file, that would be retrvied when Twitter would redirect the user to the callback url. In the file, add the following snippet in the head.

    <!DOCTYPE html>
    <html>
    	<head>
    		<script type="text/javascript">window.close();</script>
    		<title>Callback Title</title>
    		<meta charset="UTF-8">
    		<meta name="viewport" content="width=device-width, initial-scale=1.0">
    	</head>
    	<body></body>
    </html>

API Reference:

  • twttr.init: This function is called to initalize the twitter-client library. Parameters:

    • Options: [Object]
      • api_key: Twitter Consumer Key
      • request_url: Application Endpoint to obtain a request token.
  • twttr.connect: This function is used allow the user to login and authorize the application. Parameters:

    • Callback: [Function]

      • The callback function accepts a single parameter, i.e. response as its arguments The parameter would contain the following keys:
        • success: [Boolean] : True on Success, False on Failure
        • message: [String] : If success is False, then contains a error message indicating the error, ignored when success is true.
        • oauth_token: [String] : Contains the oauth-token, similar to the one obtained by communicating with the request_url
        • oauth_verifier: [String] : Contains the oauth-verifier, This token would be used by your application to obtain a user access token.

      Note: The following tokens are mutually exclusive a. message b. oauth_token, oauth_verifier Either a or b would be present at a time, not both.

License

MIT