GithubHelp home page GithubHelp logo

omniauth-reddit's Introduction

Reddit OAuth2 Strategy for OmniAuth 1.0.

Supports the OAuth 2.0 server-side and client-side flows. Read the Reddit docs for more details: http://www.reddit.com/dev/api/oauth

Installing

Add to your Gemfile:

gem 'omniauth-reddit', :git => 'git://github.com/jackdempsey/omniauth-reddit.git'

Then bundle install.

Usage

OmniAuth::Strategies::Reddit is simply a Rack middleware. Read the OmniAuth 1.0 docs for detailed instructions: https://github.com/intridea/omniauth.

Here's a quick example, adding the middleware to a Rails app in config/initializers/omniauth.rb:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :reddit, ENV['REDDIT_KEY'], ENV['REDDIT_SECRET']
end

Configuring

  • scope: A comma-separated list of permissions you want to request from the user. See the Reddit docs for a full list of available permissions: http://www.reddit.com/dev/api/oauth

License

Copyright (c) 2012 by Jack Dempsey

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

omniauth-reddit's People

Contributors

jackdempsey avatar jdg avatar johnkozan avatar kayakyakr avatar lalithr95 avatar pasta avatar wbarnhill avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

omniauth-reddit's Issues

refresh token

Does not seem to have built in support for retrieving a refresh token, so the auth expires after 1 hour without the ability to refresh the token. You have to logout and re-authenticate.

403 from Rails after callback

I'm probably doing something wrong, or omniauth-reddit isn't up-to-date with Reddit's API.

Omniauth.rb:
provider :reddit, REDDIT_KEY, REDDIT_SECRET, {:scope => 'read,mysubreddits'}
(also tried :scope => 'read' with same result)

Approval page shows my app's name, but callback is 403 with this url:

http://localhost:3000/auth/reddit/callback?state=a5a...0516&code=uTA...Vj0

My callback URL is http://localhost:3000/auth/reddit/callback

Thanks for creating this gem! I have big plans for it.

Scope not working

I am continuously getting an error:

Could not authenticate you from Reddit because "Invalid scope".

This is with default settings. How would I define a scope and is it really necessary?

Using it with Rails.

OAuth2::Error ... invalid_grant: {"error": "invalid_grant"}

I installed the gem as directed, and placed this into my config/initializers/omniauth.rb file:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :reddit, '[FILTERED APP ID]', '[FILTERED APP SECRET', {:duration => "permanent", :scope => "identity"}
end

It brings me to the page where I can click "allow" on reddit, and sends the state and code to my callback, but immediately crashes with the OAuth::Error:

invalid_grant: {"error": "invalid_grant"}`

Here's a small trace (pertinent to omniauth):

oauth2 (1.2.0) lib/oauth2/client.rb:140:in `get_token'
oauth2 (1.2.0) lib/oauth2/strategy/auth_code.rb:29:in `get_token'
omniauth-oauth2 (1.4.0) lib/omniauth/strategies/oauth2.rb:89:in `build_access_token'
/usr/local/rvm/gems/ruby-2.3.0/bundler/gems/omniauth-reddit-4e54423f2d8a/lib/omniauth/strategies/reddit.rb:35:in `build_access_token'
omniauth-oauth2 (1.4.0) lib/omniauth/strategies/oauth2.rb:73:in `callback_phase'
omniauth (1.3.1) lib/omniauth/strategy.rb:227:in `callback_call'
omniauth (1.3.1) lib/omniauth/strategy.rb:184:in `call!'
omniauth (1.3.1) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.3.1) lib/omniauth/builder.rb:63:in `call'

Reddit asks for authorization again (after initially accepting it)

Is the following a usual case :-

  1. User authenticates via Reddit (permanent duration in this case)
  2. User accepts to authorize his/her account
  3. User logs out
  4. User comes back and login using Reddit again
  5. The problem i am seeing is here; Reddit is prompting the user to accept the authorization again.

Wouldn't Reddit already know that the app has been authorized by the user. as can be seen under the apps tab of the user setting?

Or am i missing something here?

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.