omniauth-tumblr-1.2/0000755000004100000410000000000012637560454014547 5ustar www-datawww-dataomniauth-tumblr-1.2/Rakefile0000644000004100000410000000022412637560454016212 0ustar www-datawww-data#!/usr/bin/env rake require "bundler/gem_tasks" require 'rspec/core/rake_task' desc "Run specs" RSpec::Core::RakeTask.new task :default => :spec omniauth-tumblr-1.2/Gemfile.lock0000644000004100000410000000130212637560454016765 0ustar www-datawww-dataPATH remote: . specs: omniauth-tumblr (1.2) multi_json omniauth-oauth (~> 1.0) GEM remote: https://rubygems.org/ specs: diff-lcs (1.1.3) hashie (3.4.3) multi_json (1.11.2) oauth (0.4.7) omniauth (1.2.2) hashie (>= 1.2, < 4) rack (~> 1.0) omniauth-oauth (1.1.0) oauth omniauth (~> 1.0) rack (1.6.4) rake (0.9.2.2) rspec (2.11.0) rspec-core (~> 2.11.0) rspec-expectations (~> 2.11.0) rspec-mocks (~> 2.11.0) rspec-core (2.11.1) rspec-expectations (2.11.2) diff-lcs (~> 1.1.3) rspec-mocks (2.11.1) PLATFORMS ruby DEPENDENCIES omniauth-tumblr! rake rspec BUNDLED WITH 1.10.6 omniauth-tumblr-1.2/Gemfile0000644000004100000410000000004712637560454016043 0ustar www-datawww-datasource 'https://rubygems.org' gemspec omniauth-tumblr-1.2/.rspec0000644000004100000410000000001012637560454015653 0ustar www-datawww-data--color omniauth-tumblr-1.2/.ruby-version0000644000004100000410000000000612637560454017210 0ustar www-datawww-data2.2.3 omniauth-tumblr-1.2/spec/0000755000004100000410000000000012637560454015501 5ustar www-datawww-dataomniauth-tumblr-1.2/spec/omniauth/0000755000004100000410000000000012637560454017325 5ustar www-datawww-dataomniauth-tumblr-1.2/spec/omniauth/strategies/0000755000004100000410000000000012637560454021477 5ustar www-datawww-dataomniauth-tumblr-1.2/spec/omniauth/strategies/tumblr_spec.rb0000644000004100000410000000057612637560454024353 0ustar www-datawww-datarequire 'spec_helper' describe OmniAuth::Strategies::Tumblr do subject do OmniAuth::Strategies::Tumblr.new({}) end context "client options" do it 'should have correct name' do subject.options.name.should eq("tumblr") end it 'should have correct site' do subject.options.client_options.site.should eq("https://www.tumblr.com") end end end omniauth-tumblr-1.2/spec/spec_helper.rb0000644000004100000410000000361512637560454020324 0ustar www-datawww-data$:.unshift File.expand_path('..', __FILE__) $:.unshift File.expand_path('../../lib', __FILE__) require 'rspec' require 'omniauth' require 'omniauth-tumblr' RSpec.configure do |config| config.extend OmniAuth::Test::StrategyMacros, :type => :strategy end # Copied/inlined from omniauth-google2 # TODO this should also be part of omniauth-oauth # NOTE it would be useful if this lived in omniauth-oauth2 eventually shared_examples 'an oauth2 strategy' do describe '#client' do it 'should be initialized with symbolized client_options' do @options = { :client_options => { 'authorize_url' => 'https://example.com' } } subject.client.options[:authorize_url].should == 'https://example.com' end end describe '#authorize_params' do it 'should include any authorize params passed in the :authorize_params option' do @options = { :authorize_params => { :foo => 'bar', :baz => 'zip' } } subject.authorize_params['foo'].should eq('bar') subject.authorize_params['baz'].should eq('zip') end it 'should include top-level options that are marked as :authorize_options' do @options = { :authorize_options => [:scope, :foo], :scope => 'http://bar', :foo => 'baz' } subject.authorize_params['scope'].should eq('http://bar') subject.authorize_params['foo'].should eq('baz') end end describe '#token_params' do it 'should include any token params passed in the :token_params option' do @options = { :token_params => { :foo => 'bar', :baz => 'zip' } } subject.token_params['foo'].should eq('bar') subject.token_params['baz'].should eq('zip') end it 'should include top-level options that are marked as :token_options' do @options = { :token_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' } subject.token_params['scope'].should eq('bar') subject.token_params['foo'].should eq('baz') end end endomniauth-tumblr-1.2/lib/0000755000004100000410000000000012637560454015315 5ustar www-datawww-dataomniauth-tumblr-1.2/lib/omniauth/0000755000004100000410000000000012637560454017141 5ustar www-datawww-dataomniauth-tumblr-1.2/lib/omniauth/strategies/0000755000004100000410000000000012637560454021313 5ustar www-datawww-dataomniauth-tumblr-1.2/lib/omniauth/strategies/tumblr.rb0000644000004100000410000000300712637560454023145 0ustar www-datawww-datarequire 'omniauth-oauth' require 'multi_json' module OmniAuth module Strategies class Tumblr < OmniAuth::Strategies::OAuth option :name, 'tumblr' option :client_options, {:site => 'https://www.tumblr.com', :request_token_path => "/oauth/request_token", :access_token_path => "/oauth/access_token", :authorize_path => "/oauth/authorize"} uid { raw_info['name'] } info do { :nickname => raw_info['name'], :name => raw_info['name'], :blogs => raw_info['blogs'].map do |b| { :name => b['name'], :url => b['url'], :title => b['title'] } end, :avatar => avatar_url } end extra do { :raw_info => raw_info.merge({ :avatar => avatar_url }) } end def user tumblelogs = user_hash['tumblr']['tumblelog'] if tumblelogs.kind_of?(Array) @user ||= tumblelogs[0] else @user ||= tumblelogs end end def raw_info url = 'http://api.tumblr.com/v2/user/info' @raw_info ||= MultiJson.decode(access_token.get(url).body)['response']['user'] end def avatar_url url = "http://api.tumblr.com/v2/blog/#{ raw_info['blogs'].first['url'].sub(%r|^https?://|, '').sub(%r|/?$|, '') }/avatar" res = access_token.get(url).body @avatar_url ||= MultiJson.decode(res)['response']['avatar_url'] end end end end omniauth-tumblr-1.2/lib/omniauth-tumblr/0000755000004100000410000000000012637560454020444 5ustar www-datawww-dataomniauth-tumblr-1.2/lib/omniauth-tumblr/version.rb0000644000004100000410000000007612637560454022461 0ustar www-datawww-datamodule Omniauth module Tumblr VERSION = "1.2" end end omniauth-tumblr-1.2/lib/omniauth-tumblr.rb0000644000004100000410000000010612637560454020766 0ustar www-datawww-datarequire "omniauth-tumblr/version" require 'omniauth/strategies/tumblr'omniauth-tumblr-1.2/metadata.yml0000644000004100000410000000522712637560454017060 0ustar www-datawww-data--- !ruby/object:Gem::Specification name: omniauth-tumblr version: !ruby/object:Gem::Version version: '1.2' platform: ruby authors: - Jamie Wilkinson autorequire: bindir: bin cert_chain: [] date: 2015-11-15 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: omniauth-oauth requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '1.0' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '1.0' - !ruby/object:Gem::Dependency name: multi_json requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: rspec requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: rake requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' description: OmniAuth strategy for Tumblr email: - jamie@jamiedubs.com executables: [] extensions: [] extra_rdoc_files: [] files: - ".gitignore" - ".rspec" - ".ruby-version" - Gemfile - Gemfile.lock - README.md - Rakefile - lib/omniauth-tumblr.rb - lib/omniauth-tumblr/version.rb - lib/omniauth/strategies/tumblr.rb - omniauth-tumblr.gemspec - spec/omniauth/strategies/tumblr_spec.rb - spec/spec_helper.rb homepage: https://github.com/jamiew/omniauth-tumblr licenses: [] metadata: {} post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: 1.3.6 requirements: [] rubyforge_project: rubygems_version: 2.4.5.1 signing_key: specification_version: 4 summary: OmniAuth strategy for Tumblr test_files: - spec/omniauth/strategies/tumblr_spec.rb - spec/spec_helper.rb omniauth-tumblr-1.2/.gitignore0000644000004100000410000000003612637560454016536 0ustar www-datawww-data.bundle .DS_Store .gems *.gem omniauth-tumblr-1.2/omniauth-tumblr.gemspec0000644000004100000410000000200012637560454021233 0ustar www-datawww-data# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "omniauth-tumblr/version" Gem::Specification.new do |gem| gem.name = "omniauth-tumblr" gem.version = Omniauth::Tumblr::VERSION gem.authors = ["Jamie Wilkinson"] gem.email = ["jamie@jamiedubs.com"] gem.homepage = "https://github.com/jamiew/omniauth-tumblr" gem.description = %q{OmniAuth strategy for Tumblr} gem.summary = gem.description gem.files = `git ls-files`.split("\n") gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } gem.require_paths = ["lib"] gem.add_runtime_dependency 'omniauth-oauth', '~> 1.0' gem.add_runtime_dependency 'multi_json' gem.add_development_dependency 'rspec' #, "~> 2.9" gem.add_development_dependency 'rake' #, '~> 0.9' gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if gem.respond_to? :required_rubygems_version= end omniauth-tumblr-1.2/README.md0000644000004100000410000000301312637560454016023 0ustar www-datawww-dataOmniAuth Tumblr ================ This gem is an OmniAuth 1.0 Strategy for authenticating with the [Tumblr API](http://developers.tumblr.com) An example Rails application is available: Setup ----- Register your application with [Tumblr](http://www.tumblr.com/oauth/apps). *Important*: your callback URL needs to be specified as `http://[hostname]/auth/tumblr/callback`. The Tumblr API does not respect the dynamic ?oauth_callback URL passed by Omniauth. ([related thread](https://groups.google.com/forum/?fromgroups#!searchin/tumblr-api/callback$20url/tumblr-api/5k_afNDUB5s/gfaNMnRtINoJ)) In order to authenticate with Tumblr in both development and production we recommend registering a "-dev" app with Tumblr which points at localhost:3000 or yourapp.dev (not ideal) Using services like https://ngrok.com works like a charm. Usage ----- Get started by adding the Tumblr strategy to your `Gemfile`: ```ruby gem 'omniauth-tumblr' ``` In a Rails app, add the Tumblr provider to your Omniauth middleware, e.g. in a file like @config/initializers/omniauth.rb@: ```ruby Rails.application.config.middleware.use OmniAuth::Builder do provider :tumblr, ENV['TUMBLR_KEY'], ENV['TUMBLR_SECRET'] end ``` In any Rack app you can add the Tumblr strategy like so: ```ruby use OmniAuth::Builder do provider :tumblr, ENV['TUMBLR_KEY'], ENV['TUMBLR_SECRET'] end ``` License ------- Copyright (c) 2011-2012 [Jamie Wilkinson](http://jamiedubs.com) This source code released under an MIT license.