No commit activity in last 3 years
No release in over 3 years
OmniAuth OAuth2 strategy for Douban.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

OmniAuth-Douban-OAuth2

This is the OmniAuth strategy for authenticating to Douban. To use it, you'll need to sign up for an OAuth2 Application Key and Secret on the Open Platform

How to install

gem install omniauth-douban-oauth2

Basic Usage

use OmniAuth::Builder do
  provider :douban, ENV['DOUBAN_KEY'], ENV['DOUBAN_SECRET']
end

Examples

Rails

Rails + Devise + Omniauth-douban-oauth2

Sinatra

require 'sinatra'
require 'omniauth-douban-oauth2'

KEY = 'your api key'
SECRET = 'your api secret'

use Rack::Session::Cookie

use OmniAuth::Builder do
  provider :douban, KEY, SECRET
end 

get '/' do
   '<a href="/auth/douban">Douban</a>' 
end

get '/auth/douban/callback' do
  auth = env['omniauth.auth']
  auth.to_hash.to_s
end

get '/auth/failure' do
  'auth failure'
end

Auth Hash

Here's an example Auth Hash available in request.env['omniauth.auth']:

{
       "provider" => "douban",
            "uid" => "2217855",
           "info" => {
            "name" => "小松其实还没有",
        "nickname" => "xiaosong",
        "location" => "陕西西安",
           "image" => "http://img3.douban.com/icon/u2217855-34.jpg",
            "urls" => { :alt => "http://www.douban.com/people/xiaosong/" },
     "description" => "你确实知道就必须证明",
    },
    "credentials" => {
                "token" => "6516f0d........", # OAuth 2.0 access_token
        "refresh_token" => "30c8c560..........", # OAuth 2.0 refresh_token
           "expires_at" => 1357053699,        # when the access token expires (it always will)
              "expires" => true               # this will always be true
    },
          "extra" => {
        "raw_info" => {
               "loc_id" => "118371",
                 "name" => "小松其实还没有",
              "created" => "2008-02-05 15:26:44",
             "loc_name" => "陕西西安",
               "avatar" => "http://img3.douban.com/icon/u2217855-34.jpg",
            "signature" => "啊我要增肥...",
                  "uid" => "xiaosong",
                  "alt" => "http://www.douban.com/people/xiaosong/",
                   "id" => "2217855",
                 "desc" => "你确实知道就必须证明"
        }
    }
}