Giter Site home page Giter Site logo

nextacademy / sign_in_with_twitter_sample Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lfcipriani/sign_in_with_twitter_sample

0.0 2.0 3.0 187 KB

A minimal, standalone web app to help you understand how to enable the users of your website to Sign in with their Twitter accounts.

License: Apache License 2.0

sign_in_with_twitter_sample's Introduction

Sign in with Twitter sample

This is a minimal, ruby standalone web app to help you understand how to enable the users of your website to Sign in with their Twitter accounts.

  • built as a simple Sinatra web app
  • easy to install and play
  • no dependency with external databases
  • uses simple_oauth gem to enable free choice of HTTP client
  • code comments linked to official Twitter docs

Getting started

The requirement is to have ruby and bundler installed.

  1. Create an app at dev.twitter.com/apps with:
  2. Clone this repo
  3. Run bundle install to install dependencies
  4. Rename config/twitter_oauth.yml.sample to config/twitter_oauth.yml
  5. Fill twitter_oauth.yml with your app consumer key and consumer secret got at step 1
  6. Optionally, change the var ACCOUNT_TO_FOLLOW in app.rb to set what account will be followed
  7. Run sign_in_start script
  8. Open http://dev.yoursite.com:4567 in your browser

The web app

This web app simply require the user to Sign in with Twitter to be able to access "awesome" features. The features provided are the ability to create a automatic follow to an account (see step 6 above) or just to check the logged user info, which are resources only available if users authorize your app to have access to it.

Please, take into account that this sample web app is intended only for educational purposes. I do not recommend to use it as is in production.

The code

This app code is full of comments explaining what's happening in high level and linking to the official docs. The signing in implementation is concentrated in lib/twitter_sign_in.rb file, and app.rb file implements the high level flow of authentication.

Data persistence is achieved with Daybreak gem and a default db/signin.db is used to store tokens and user info.

At frontend side, I tried to keep it simple and just used Twitter bootstrap. All views and layouts are in views folder.

I built this app using ruby 2, but it may work in other versions as well. Let me know if you have any problems to use it.

References

Bitdeli Badge

sign_in_with_twitter_sample's People

Contributors

lfcipriani avatar bitdeli-chef avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.