GithubHelp home page GithubHelp logo

ocowchun / omniauth-stackexchange Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nashby/omniauth-stackexchange

0.0 1.0 0.0 20 KB

StackExchange OAuth strategy for OmniAuth

License: MIT License

Ruby 100.00%

omniauth-stackexchange's Introduction

OmniAuth StackExchange TravisCI

This gem contains the StackExchange strategy for OmniAuth.

StackExchange uses the OAuth2 flow, you can read about it here: https://api.stackexchange.com/docs/authentication

How To Use It

So let's say you're using Rails, you need to add the strategy to your Gemfile:

gem 'omniauth-stackexchange'

You can pull them in directly from github e.g.:

gem 'omniauth-stackexchange', git: 'https://github.com/nashby/omniauth-stackexchange.git'

Once these are in, you need to add the following to your config/initializers/omniauth.rb:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :stackexchange, 'client_id', 'client_secret', public_key: 'key', site: 'stackoverflow'
end

or with Devise to your config/initializers/devise.rb

  config.omniauth :meetup, ENV['client_id'], ENV['client_secret'], callback_url: 'http://example.com/users/auth/stackexchange/callback'

Starting from version 1.4 in omniauth-oauth2 you must provide same callback url you have provided on API dashboard otherwise authentication won't work.

You will obviously have to put in your client_id, client_secret and public_key, which you get when you register your app with StackExchange (they call them Client Id, Client Secret and Key).

You will also need to specify a site option to uniquely identify the StackExchange site (e.g. stackoverflow or superuser) you wish to authenticate against. A list of valid site api keys can be found at https://api.stackexchange.com/docs/sites. It's stackoverflow by default.

If your application needs to be able to support multiple StackExchange sites, you can pass the site api key as the value for a GET parameter named sites (e.g. /auth/stackexchange?site=superuser)

Now just follow the README at: https://github.com/intridea/omniauth

Supported Rubies

OmniAuth StackExchange is tested under 1.9.3.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

Copyright (c) 2012 by Vasiliy Ermolovich

omniauth-stackexchange's People

Contributors

nashby avatar gauravtiwari avatar cdellinger avatar yimajo avatar

Watchers

ocowchun(Ben Yeh) 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.