omniauth-tumblr 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.md +42 -0
- data/lib/omniauth-tumblr.rb +2 -0
- data/lib/omniauth-tumblr/version.rb +5 -0
- data/lib/omniauth/strategies/tumblr.rb +43 -0
- data/omniauth-tumblr.gemspec +22 -0
- metadata +86 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.DS_Store
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
OmniAuth Tumblr
|
2
|
+
================
|
3
|
+
|
4
|
+
This gem is an OmniAuth 1.0 Strategy for authenticating with the [Tumblr API](http://developers.tumblr.com)
|
5
|
+
|
6
|
+
|
7
|
+
Usage
|
8
|
+
-----
|
9
|
+
|
10
|
+
Register your application with Tumblr. *Important*: specify a default callback URL or
|
11
|
+
Tumblr will throw 400 Bad Request errors. Any URL is fine.
|
12
|
+
|
13
|
+
Get started by adding the Tumblr strategy to your `Gemfile` along with Omniauth:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'omniauth'
|
17
|
+
gem 'omniauth-tumblr'
|
18
|
+
```
|
19
|
+
|
20
|
+
Then add the Tumblr strategy to your Rack middleware:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
use OmniAuth::Builder do
|
24
|
+
provider :tumblr, ENV['TUMBLR_KEY'], ENV['TUMBLR_SECRET']
|
25
|
+
end
|
26
|
+
```
|
27
|
+
|
28
|
+
In Rails, create a file like @config/initializers/omniauth.com@:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
32
|
+
provider :tumblr, ENV['TUMBLR_KEY'], ENV['TUMBLR_SECRET']
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
|
37
|
+
License
|
38
|
+
-------
|
39
|
+
|
40
|
+
This source code released under an MIT license.
|
41
|
+
|
42
|
+
(c) 2011 Jamie Wilkinson
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'omniauth-oauth'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
class Tumblr < OmniAuth::Strategies::OAuth
|
7
|
+
|
8
|
+
option :name, 'tumblr'
|
9
|
+
option :client_options, {:site => 'http://www.tumblr.com'}
|
10
|
+
|
11
|
+
uid { user['name'] }
|
12
|
+
|
13
|
+
info do
|
14
|
+
{
|
15
|
+
'nickname' => user['name'],
|
16
|
+
'name' => user['title'],
|
17
|
+
'image' => user['avatar_url'],
|
18
|
+
'urls' => {
|
19
|
+
'website' => user['url'],
|
20
|
+
}
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
extra do
|
25
|
+
{'user_hash' => user}
|
26
|
+
end
|
27
|
+
|
28
|
+
def user
|
29
|
+
tumblelogs = user_hash['tumblr']['tumblelog']
|
30
|
+
if tumblelogs.kind_of?(Array)
|
31
|
+
@user ||= tumblelogs[0]
|
32
|
+
else
|
33
|
+
@user ||= tumblelogs
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def user_hash
|
38
|
+
url = "http://www.tumblr.com/api/authenticate"
|
39
|
+
@user_hash ||= Hash.from_xml(@access_token.get(url).body)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "omniauth-tumblr/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "omniauth-tumblr"
|
7
|
+
gem.version = Omniauth::Tumblr::VERSION
|
8
|
+
gem.authors = ["Jamie Wilkinson"]
|
9
|
+
gem.email = ["jamie@jamiedubs.com"]
|
10
|
+
gem.homepage = "https://github.com/jamiew/omniauth-tumblr"
|
11
|
+
gem.description = %q{OmniAuth strategy for Tumblr}
|
12
|
+
gem.summary = gem.description
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split("\n")
|
15
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
gem.require_paths = ["lib"]
|
18
|
+
|
19
|
+
gem.add_runtime_dependency 'omniauth-oauth', '~> 1.0'
|
20
|
+
|
21
|
+
gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if gem.respond_to? :required_rubygems_version=
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-tumblr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 9
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: "0.1"
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Jamie Wilkinson
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-11-30 00:00:00 Z
|
18
|
+
dependencies:
|
19
|
+
- !ruby/object:Gem::Dependency
|
20
|
+
name: omniauth-oauth
|
21
|
+
prerelease: false
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 15
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 0
|
31
|
+
version: "1.0"
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
description: OmniAuth strategy for Tumblr
|
35
|
+
email:
|
36
|
+
- jamie@jamiedubs.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files: []
|
42
|
+
|
43
|
+
files:
|
44
|
+
- .gitignore
|
45
|
+
- README.md
|
46
|
+
- lib/omniauth-tumblr.rb
|
47
|
+
- lib/omniauth-tumblr/version.rb
|
48
|
+
- lib/omniauth/strategies/tumblr.rb
|
49
|
+
- omniauth-tumblr.gemspec
|
50
|
+
homepage: https://github.com/jamiew/omniauth-tumblr
|
51
|
+
licenses: []
|
52
|
+
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
hash: 3
|
64
|
+
segments:
|
65
|
+
- 0
|
66
|
+
version: "0"
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 23
|
73
|
+
segments:
|
74
|
+
- 1
|
75
|
+
- 3
|
76
|
+
- 6
|
77
|
+
version: 1.3.6
|
78
|
+
requirements: []
|
79
|
+
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 1.8.11
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: OmniAuth strategy for Tumblr
|
85
|
+
test_files: []
|
86
|
+
|