GithubHelp home page GithubHelp logo

isabella232 / facebook-signed-request Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wooga/facebook-signed-request

0.0 0.0 0.0 30 KB

Ruby Gem which parses and validates Facebook signed requests

License: MIT License

Ruby 100.00%

facebook-signed-request's Introduction

Usage

    require 'facebook-signed-request'

    # The secret can be set globally
    Facebook::SignedRequest.secret = "dkhsdfhjsd123d2ed3q1wd222qd2"
    request = Facebook::SignedRequest.new( params[:signed_request] )

    # or as an optional parameter for individual calls
    request = Facebook::SignedRequest.new( params[:signed_request], secret: secret )

    request.valid?
    # => true / false

    request.errors
    # => [
    #  "Invalid Format. See http://developers.facebook.com/docs/authentication/signed_request/",
    #  "Invalid Base64 encoding for signature",
    #  "Invalid Base64 Encoding for data",
    #  "Invalid JSON object",
    #  "Invalid Algorithm. Expected: HMAC-SHA256",
    #  "Signatures do not match.
    #]

    request.data
    # => {
    #      :algorithm   => "HMAC-SHA256",
    #      :expires     => 1308988800,
    #      :issued_at   => 1308985018,
    #      :oauth_token => "114998258593813|2.AQBAttRlLVnwqNPZ.3600.1308988800…",
    #      :user => {
    #        :country => "de",
    #        :locale  => "en_US",
    #        :age     => {"min"=>21}
    #      },
    #      :user_id => "100000656666199"
    #    }


    Facebook::SignedRequest.encode_and_sign { :foo => bar }
    # => g_eE3hoQDPKFusHcc_Tj7k2xxo3mCKsOEXKMViq0pAY=.eyJmb28iOiJiYXIifQ==

Run the tests with rake test:units

facebook-signed-request's People

Contributors

a2ikm avatar doubleday avatar hukl 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.