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

omniauth-douban-oauth2

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

omniauth-douban-oauth2

  • 0.0.7
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

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" => "你确实知道就必须证明"
        }
    }
}

FAQs

Package last updated on 09 Dec 2013

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