Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graph-api

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graph-api

  • 1.0.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

GraphAPI

GraphAPI is a Ruby Gem created to simplifiy and help manage authentication using the Facebook Graph API.

Usage

Here is how to use it.

Add it to your Gemfile

gem 'graph-api', require: 'graph_api'

Set up your Facebook Appications constants

You will have to configure the gem before using it. Here is an example setup.

GraphAPI.config do
  app_secret   '124ca2a483f12723cafa7a5da33a3492'      # The Facebook Application Secret
  client_id    '234513432316919'                       # The Facebook Application Id
  callback_url 'http://example.com/facebook_callback/' # URI for receiving the Facebook code param
  logout_url   'http://example.com/logout/'            # URI to redirect to when logging out
  access_scope [:offline_access, :email, :user_photos] # The Facebook application requirements
  user_fields  [:id, :picture, :name, :gender, :email] # The user fields pulled for
end

Visit https://developers.facebook.com/apps to register your Facebook application or checkout https://developers.facebook.com/docs/reference/api/user/ for a list of user fields and permissions.

Add it to your Application

Once configured you will be able to use GraphAPI to retrieve any Facebook user fields in your application. Here is basic example using Sinatra.

get '/facebook_login' do
  redirect GraphAPI.auth_url
end

get '/facebook_callback' do
  @facebook_user = GraphAPI.new(false, params[:code])
  session[:auth_token] = @facebook_user.auth_token
  render :signed_in
end

get '/profile'
  @facebook_user = GraphAPI.new(session[:auth_token])
  logger.info "User #{@facebook_user.name} viewed their profile."
  render :profile
end

License

WTFPL © 2012 Nick Barth

FAQs

Package last updated on 30 Oct 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc