omniauth-youtube 1.0 → 2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -0
- data/Gemfile +2 -0
- data/README.md +29 -5
- data/lib/omniauth-youtube/version.rb +1 -1
- data/lib/omniauth/strategies/youtube.rb +24 -12
- data/omniauth-youtube.gemspec +5 -5
- metadata +39 -58
    
        data/.gitignore
    CHANGED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -3,30 +3,54 @@ OmniAuth YouTube | |
| 3 3 |  | 
| 4 4 | 
             
            This is an [OmniAuth 1.0](https://github.com/intridea/omniauth) strategy for authenticating to YouTube.
         | 
| 5 5 |  | 
| 6 | 
            -
            Get a  | 
| 6 | 
            +
            Get a Google Oauth2.0 API key at their [API console](https://code.google.com/apis/console/)
         | 
| 7 7 |  | 
| 8 | 
            -
             | 
| 8 | 
            +
            Your key (AKA client_id) looks like "555555555555.apps.googleusercontent.com"; a longer key like "555555555-xxxxyyyzzz"
         | 
| 9 | 
            +
            won't work. See [this issue](https://github.com/zquestz/omniauth-google-oauth2/issues/10#issuecomment-5720475) for discussion.
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            An example Rails 3.2 application using omniauth and omniauth-youtube is also available:
         | 
| 9 12 | 
             
            <https://github.com/jamiew/omniauth-rails-app>
         | 
| 10 13 |  | 
| 11 14 |  | 
| 12 15 | 
             
            Usage
         | 
| 13 16 | 
             
            -----
         | 
| 14 17 |  | 
| 15 | 
            -
            In a  | 
| 18 | 
            +
            In a Rack application:
         | 
| 16 19 |  | 
| 17 20 | 
             
            ```ruby
         | 
| 18 21 | 
             
            use OmniAuth::Builder do
         | 
| 19 | 
            -
              provider :youtube, ENV['YOUTUBE_KEY'], ENV['YOUTUBE_SECRET']
         | 
| 22 | 
            +
              provider :youtube, ENV['YOUTUBE_KEY'], ENV['YOUTUBE_SECRET'], {:access_type => 'online', :approval_prompt => ''}
         | 
| 20 23 | 
             
            end
         | 
| 24 | 
            +
            ```
         | 
| 21 25 |  | 
| 22 26 | 
             
            For Rails, put this in `config/initializers/omniauth.rb`:
         | 
| 23 27 |  | 
| 24 28 | 
             
            ```ruby
         | 
| 25 29 | 
             
            Rails.application.config.middleware.use OmniAuth::Builder do
         | 
| 26 | 
            -
              provider :youtube, ENV['YOUTUBE_KEY'], ENV['YOUTUBE_SECRET']
         | 
| 30 | 
            +
              provider :youtube, ENV['YOUTUBE_KEY'], ENV['YOUTUBE_SECRET'], {:access_type => 'online', :approval_prompt => ''}
         | 
| 27 31 | 
             
            end
         | 
| 28 32 | 
             
            ```
         | 
| 29 33 |  | 
| 34 | 
            +
            Restart your server and visit */auth/youtube* to try it out
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            Options
         | 
| 37 | 
            +
            -------
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            Re. :access_type and :approval_prompt, via (omniauth-google-oauth2)[https://github.com/zquestz/omniauth-google-oauth2/blob/master/examples/omni_auth.rb]:
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            If you don't need a refresh token -- if you're only using Google for account creation/auth and don't need google services -- set the access_type to 'online', vs. 'offline'
         | 
| 42 | 
            +
            Also, set the approval prompt to an empty string, since otherwise it will be set to 'force', which makes users manually approve to the Oauth every time they log in.
         | 
| 43 | 
            +
            See <http://googleappsdeveloper.blogspot.com/2011/10/upcoming-changes-to-oauth-20-endpoint.html>
         | 
| 44 | 
            +
             | 
| 45 | 
            +
             | 
| 46 | 
            +
             | 
| 47 | 
            +
            Authors
         | 
| 48 | 
            +
            -------
         | 
| 49 | 
            +
             | 
| 50 | 
            +
            * [Jamie Wilkinson (@jamiew)](https://github.com/jamiew)
         | 
| 51 | 
            +
            * [@tarko](https://github.com/tarko)
         | 
| 52 | 
            +
            * [Simon Gate (@simon)](https://github.com/simon)
         | 
| 53 | 
            +
             | 
| 30 54 |  | 
| 31 55 | 
             
            License
         | 
| 32 56 | 
             
            -------
         | 
| @@ -1,34 +1,36 @@ | |
| 1 | 
            -
            require 'omniauth- | 
| 1 | 
            +
            require 'omniauth-oauth2'
         | 
| 2 2 | 
             
            require 'multi_json'
         | 
| 3 3 |  | 
| 4 4 | 
             
            module OmniAuth
         | 
| 5 5 | 
             
              module Strategies
         | 
| 6 | 
            -
                class YouTube < OmniAuth::Strategies:: | 
| 6 | 
            +
                class YouTube < OmniAuth::Strategies::OAuth2
         | 
| 7 | 
            +
             | 
| 7 8 | 
             
                  option :name, 'youtube'
         | 
| 9 | 
            +
             | 
| 8 10 | 
             
                  option :client_options, {
         | 
| 9 | 
            -
                    :site => 'https://www. | 
| 10 | 
            -
                    : | 
| 11 | 
            -
                    : | 
| 12 | 
            -
                    :authorize_path => '/accounts/OAuthAuthorizeToken',
         | 
| 11 | 
            +
                    :site => 'https://www.youtube.com',
         | 
| 12 | 
            +
                    :authorize_url => 'https://accounts.google.com/o/oauth2/auth',
         | 
| 13 | 
            +
                    :token_url => 'https://accounts.google.com/o/oauth2/token'
         | 
| 13 14 | 
             
                  }
         | 
| 14 15 |  | 
| 15 | 
            -
                   | 
| 16 | 
            -
             | 
| 17 | 
            -
                  option :request_params, {
         | 
| 18 | 
            -
                    :scope => 'http://gdata.youtube.com'
         | 
| 16 | 
            +
                  option :authorize_params, {
         | 
| 17 | 
            +
                    :scope => 'http://gdata.youtube.com https://www.googleapis.com/auth/userinfo.email'
         | 
| 19 18 | 
             
                  }
         | 
| 20 19 |  | 
| 21 | 
            -
                  uid { user['id'] }
         | 
| 20 | 
            +
                  uid { user['id']['$t'] }
         | 
| 22 21 |  | 
| 23 22 | 
             
                  info do
         | 
| 24 23 | 
             
                    {
         | 
| 25 24 | 
             
                      'uid' => user['id']['$t'],
         | 
| 26 25 | 
             
                      'nickname' => user['author'].first['name']['$t'],
         | 
| 26 | 
            +
                      'email'      => verified_email,
         | 
| 27 27 | 
             
                      'first_name' => user['yt$firstName'] && user['yt$firstName']['$t'],
         | 
| 28 28 | 
             
                      'last_name' => user['yt$lastName'] && user['yt$lastName']['$t'],
         | 
| 29 29 | 
             
                      'image' => user['media$thumbnail'] && user['media$thumbnail']['url'],
         | 
| 30 30 | 
             
                      'description' => user['yt$description'] && user['yt$description']['$t'],
         | 
| 31 | 
            -
                      'location' => user['yt$location'] && user['yt$location']['$t']
         | 
| 31 | 
            +
                      'location' => user['yt$location'] && user['yt$location']['$t'],
         | 
| 32 | 
            +
                      'channel_title' => user['title']['$t'],
         | 
| 33 | 
            +
                      'subscribers_count' => user['yt$statistics']['subscriberCount']
         | 
| 32 34 | 
             
                    }
         | 
| 33 35 | 
             
                  end
         | 
| 34 36 |  | 
| @@ -44,6 +46,16 @@ module OmniAuth | |
| 44 46 | 
             
                    @user_hash ||= MultiJson.decode(@access_token.get("http://gdata.youtube.com/feeds/api/users/default?alt=json").body)
         | 
| 45 47 | 
             
                  end
         | 
| 46 48 |  | 
| 49 | 
            +
                  def user_info
         | 
| 50 | 
            +
                    @raw_info ||= @access_token.get('https://www.googleapis.com/oauth2/v1/userinfo').parsed
         | 
| 51 | 
            +
                  end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                  private
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                  def verified_email
         | 
| 56 | 
            +
                    user_info['verified_email'] ? user_info['email'] : nil
         | 
| 57 | 
            +
                  end
         | 
| 58 | 
            +
             | 
| 47 59 | 
             
                end
         | 
| 48 60 | 
             
              end
         | 
| 49 61 | 
             
            end
         | 
    
        data/omniauth-youtube.gemspec
    CHANGED
    
    | @@ -5,10 +5,10 @@ require "omniauth-youtube/version" | |
| 5 5 | 
             
            Gem::Specification.new do |gem|
         | 
| 6 6 | 
             
              gem.name        = "omniauth-youtube"
         | 
| 7 7 | 
             
              gem.version     = Omniauth::YouTube::VERSION
         | 
| 8 | 
            -
              gem.authors     = [" | 
| 9 | 
            -
              gem.email       = [" | 
| 10 | 
            -
              gem.homepage    = "https://github.com/ | 
| 11 | 
            -
              gem.description = %q{OmniAuth strategy for YouTube}
         | 
| 8 | 
            +
              gem.authors     = ["Jamie Wilkinson"]
         | 
| 9 | 
            +
              gem.email       = ["jamie@jamiedubs.com"]
         | 
| 10 | 
            +
              gem.homepage    = "https://github.com/jamiew/omniauth-youtube"
         | 
| 11 | 
            +
              gem.description = %q{OmniAuth strategy for YouTube (OAuth 2.0)}
         | 
| 12 12 | 
             
              gem.summary     = gem.description
         | 
| 13 13 |  | 
| 14 14 | 
             
              gem.files         = `git ls-files`.split("\n")
         | 
| @@ -16,7 +16,7 @@ Gem::Specification.new do |gem| | |
| 16 16 | 
             
              gem.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
         | 
| 17 17 | 
             
              gem.require_paths = ["lib"]
         | 
| 18 18 |  | 
| 19 | 
            -
              gem.add_runtime_dependency 'omniauth- | 
| 19 | 
            +
              gem.add_runtime_dependency 'omniauth-oauth2', '~> 1.0'
         | 
| 20 20 |  | 
| 21 21 | 
             
              gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if gem.respond_to? :required_rubygems_version=
         | 
| 22 22 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,88 +1,69 @@ | |
| 1 | 
            -
            --- !ruby/object:Gem::Specification | 
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: omniauth-youtube
         | 
| 3 | 
            -
            version: !ruby/object:Gem::Version | 
| 4 | 
            -
               | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: '2.1'
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 | 
            -
              segments: 
         | 
| 7 | 
            -
              - 1
         | 
| 8 | 
            -
              - 0
         | 
| 9 | 
            -
              version: "1.0"
         | 
| 10 6 | 
             
            platform: ruby
         | 
| 11 | 
            -
            authors: | 
| 12 | 
            -
            -  | 
| 7 | 
            +
            authors:
         | 
| 8 | 
            +
            - Jamie Wilkinson
         | 
| 13 9 | 
             
            autorequire: 
         | 
| 14 10 | 
             
            bindir: bin
         | 
| 15 11 | 
             
            cert_chain: []
         | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
              name: omniauth-oauth
         | 
| 22 | 
            -
              prerelease: false
         | 
| 23 | 
            -
              requirement: &id001 !ruby/object:Gem::Requirement 
         | 
| 12 | 
            +
            date: 2012-08-04 00:00:00.000000000 Z
         | 
| 13 | 
            +
            dependencies:
         | 
| 14 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 15 | 
            +
              name: omniauth-oauth2
         | 
| 16 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 24 17 | 
             
                none: false
         | 
| 25 | 
            -
                requirements: | 
| 18 | 
            +
                requirements:
         | 
| 26 19 | 
             
                - - ~>
         | 
| 27 | 
            -
                  - !ruby/object:Gem::Version | 
| 28 | 
            -
                     | 
| 29 | 
            -
                    segments: 
         | 
| 30 | 
            -
                    - 1
         | 
| 31 | 
            -
                    - 0
         | 
| 32 | 
            -
                    version: "1.0"
         | 
| 20 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 21 | 
            +
                    version: '1.0'
         | 
| 33 22 | 
             
              type: :runtime
         | 
| 34 | 
            -
               | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 23 | 
            +
              prerelease: false
         | 
| 24 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 25 | 
            +
                none: false
         | 
| 26 | 
            +
                requirements:
         | 
| 27 | 
            +
                - - ~>
         | 
| 28 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            +
                    version: '1.0'
         | 
| 30 | 
            +
            description: OmniAuth strategy for YouTube (OAuth 2.0)
         | 
| 31 | 
            +
            email:
         | 
| 32 | 
            +
            - jamie@jamiedubs.com
         | 
| 38 33 | 
             
            executables: []
         | 
| 39 | 
            -
             | 
| 40 34 | 
             
            extensions: []
         | 
| 41 | 
            -
             | 
| 42 35 | 
             
            extra_rdoc_files: []
         | 
| 43 | 
            -
             | 
| 44 | 
            -
            files: 
         | 
| 36 | 
            +
            files:
         | 
| 45 37 | 
             
            - .gitignore
         | 
| 38 | 
            +
            - Gemfile
         | 
| 46 39 | 
             
            - README.md
         | 
| 47 40 | 
             
            - lib/omniauth-youtube.rb
         | 
| 48 41 | 
             
            - lib/omniauth-youtube/version.rb
         | 
| 49 42 | 
             
            - lib/omniauth/strategies/youtube.rb
         | 
| 50 43 | 
             
            - omniauth-youtube.gemspec
         | 
| 51 | 
            -
             | 
| 52 | 
            -
            homepage: https://github.com/lomography/omniauth-youtube
         | 
| 44 | 
            +
            homepage: https://github.com/jamiew/omniauth-youtube
         | 
| 53 45 | 
             
            licenses: []
         | 
| 54 | 
            -
             | 
| 55 46 | 
             
            post_install_message: 
         | 
| 56 47 | 
             
            rdoc_options: []
         | 
| 57 | 
            -
             | 
| 58 | 
            -
            require_paths: 
         | 
| 48 | 
            +
            require_paths:
         | 
| 59 49 | 
             
            - lib
         | 
| 60 | 
            -
            required_ruby_version: !ruby/object:Gem::Requirement | 
| 50 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 61 51 | 
             
              none: false
         | 
| 62 | 
            -
              requirements: | 
| 63 | 
            -
              - -  | 
| 64 | 
            -
                - !ruby/object:Gem::Version | 
| 65 | 
            -
                   | 
| 66 | 
            -
             | 
| 67 | 
            -
                  - 0
         | 
| 68 | 
            -
                  version: "0"
         | 
| 69 | 
            -
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 52 | 
            +
              requirements:
         | 
| 53 | 
            +
              - - ! '>='
         | 
| 54 | 
            +
                - !ruby/object:Gem::Version
         | 
| 55 | 
            +
                  version: '0'
         | 
| 56 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 70 57 | 
             
              none: false
         | 
| 71 | 
            -
              requirements: | 
| 72 | 
            -
              - -  | 
| 73 | 
            -
                - !ruby/object:Gem::Version | 
| 74 | 
            -
                  hash: 23
         | 
| 75 | 
            -
                  segments: 
         | 
| 76 | 
            -
                  - 1
         | 
| 77 | 
            -
                  - 3
         | 
| 78 | 
            -
                  - 6
         | 
| 58 | 
            +
              requirements:
         | 
| 59 | 
            +
              - - ! '>='
         | 
| 60 | 
            +
                - !ruby/object:Gem::Version
         | 
| 79 61 | 
             
                  version: 1.3.6
         | 
| 80 62 | 
             
            requirements: []
         | 
| 81 | 
            -
             | 
| 82 63 | 
             
            rubyforge_project: 
         | 
| 83 | 
            -
            rubygems_version: 1. | 
| 64 | 
            +
            rubygems_version: 1.8.24
         | 
| 84 65 | 
             
            signing_key: 
         | 
| 85 66 | 
             
            specification_version: 3
         | 
| 86 | 
            -
            summary: OmniAuth strategy for YouTube
         | 
| 67 | 
            +
            summary: OmniAuth strategy for YouTube (OAuth 2.0)
         | 
| 87 68 | 
             
            test_files: []
         | 
| 88 | 
            -
             | 
| 69 | 
            +
            has_rdoc: 
         |