GithubHelp home page GithubHelp logo

isabella232 / fb-auth Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nullscreen/fb-auth

0.0 0.0 0.0 55 KB

Authenticate users with their Facebook account

License: MIT License

Ruby 98.12% Shell 1.88%

fb-auth's Introduction

Fb::Auth

Fb::Auth can authenticate a Facebook user and return an access token with permission to manage pages of that user.

Build Status Coverage Status Dependency Status Code Climate Online docs Gem Version

The source code is available on GitHub and the documentation on RubyDoc.

Installing and Configuring Fb::Auth

First, add fb-auth to your Gemfile:

gem 'fb-auth'

Then run bundle install.

Fb::Auth will require an Client ID and an Client Secret which you can obtain after registering as a developer on Facebook for developers.

By default, Fb::Auth will look for the environment variables called FB_CLIENT_ID and FB_CLIENT_SECRET. You can put those keys in your .bash_profile and Fb::Auth will work.

export FB_CLIENT_ID="YourAppID"
export FB_CLIENT_SECRET="YourAppSecret"

Usage

Fb::Auth#url

The url method helps you obtain a URL where to redirect users who need to authenticate with their Facebook account in order to use your application:

redirect_uri = 'https://example.com/auth' # REPLACE WITH REAL ONE
Fb::Auth.new(redirect_uri: redirect_uri, scope: ["manage_pages"]).url
 # => https://www.facebook.com/dialog/oauth?client_id=...&scope=manage_pages&redirect_uri=https%3A%2F%2Fexample.com%2Fauth

Note that access is requested with permission to access email, manage pages, read insights, et cetera. See https://developers.facebook.com/docs/facebook-login/permissions

Fb::Auth#access_token

After users have authenticated with their Facebook account, they will be redirected to the redirect_uri you indicated, with an extra code query parameter, e.g. https://example.com/auth?code=1234#_=_

The access_token method allows you to get a non-expiring access token of the user:

redirect_uri = 'https://example.com/auth' # REPLACE WITH REAL ONE
code = '1234#_=_' # REPLACE WITH REAL ONE
Fb::Auth.new(redirect_uri: redirect_uri, code: code).access_token
 # => "kefjej49s82hFS@2333233222FDh66"

Development

After checking out the repo, run bin/setup to install dependencies.

Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/Fullscreen/fb-auth. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

fb-auth's People

Contributors

boroivanov avatar claudiob avatar kangkyu avatar s1v4 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.