omniauth-youtube 1.0
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 +1 -0
- data/README.md +36 -0
- data/lib/omniauth/strategies/youtube.rb +51 -0
- data/lib/omniauth-youtube/version.rb +5 -0
- data/lib/omniauth-youtube.rb +2 -0
- data/omniauth-youtube.gemspec +22 -0
- metadata +88 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.DS_Store
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
OmniAuth YouTube
|
2
|
+
================
|
3
|
+
|
4
|
+
This is an [OmniAuth 1.0](https://github.com/intridea/omniauth) strategy for authenticating to YouTube.
|
5
|
+
|
6
|
+
Get a YouTube API key on their [developer dashboard](http://code.google.com/apis/youtube/dashboard/)
|
7
|
+
|
8
|
+
An example Rails application using omniauth is also available:
|
9
|
+
<https://github.com/jamiew/omniauth-rails-app>
|
10
|
+
|
11
|
+
|
12
|
+
Usage
|
13
|
+
-----
|
14
|
+
|
15
|
+
In a rack application:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
use OmniAuth::Builder do
|
19
|
+
provider :youtube, ENV['YOUTUBE_KEY'], ENV['YOUTUBE_SECRET']
|
20
|
+
end
|
21
|
+
|
22
|
+
For Rails, put this in `config/initializers/omniauth.rb`:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
26
|
+
provider :youtube, ENV['YOUTUBE_KEY'], ENV['YOUTUBE_SECRET']
|
27
|
+
end
|
28
|
+
```
|
29
|
+
|
30
|
+
|
31
|
+
License
|
32
|
+
-------
|
33
|
+
|
34
|
+
Copyright (c) 2011 Jamie Wilkinson
|
35
|
+
|
36
|
+
This source code released under an MIT license.
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'omniauth-oauth'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
class YouTube < OmniAuth::Strategies::OAuth
|
7
|
+
option :name, 'youtube'
|
8
|
+
option :client_options, {
|
9
|
+
:site => 'https://www.google.com',
|
10
|
+
:request_token_path => '/accounts/OAuthGetRequestToken',
|
11
|
+
:access_token_path => '/accounts/OAuthGetAccessToken',
|
12
|
+
:authorize_path => '/accounts/OAuthAuthorizeToken',
|
13
|
+
}
|
14
|
+
|
15
|
+
# For the time being this option requires a fork of omniauth-oauth:
|
16
|
+
# http://github.com/jamiew/omniauth-oauth
|
17
|
+
option :request_params, {
|
18
|
+
:scope => 'http://gdata.youtube.com'
|
19
|
+
}
|
20
|
+
|
21
|
+
uid { user['id'] }
|
22
|
+
|
23
|
+
info do
|
24
|
+
{
|
25
|
+
'uid' => user['id']['$t'],
|
26
|
+
'nickname' => user['author'].first['name']['$t'],
|
27
|
+
'first_name' => user['yt$firstName'] && user['yt$firstName']['$t'],
|
28
|
+
'last_name' => user['yt$lastName'] && user['yt$lastName']['$t'],
|
29
|
+
'image' => user['media$thumbnail'] && user['media$thumbnail']['url'],
|
30
|
+
'description' => user['yt$description'] && user['yt$description']['$t'],
|
31
|
+
'location' => user['yt$location'] && user['yt$location']['$t']
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
extra do
|
36
|
+
{ 'user_hash' => user }
|
37
|
+
end
|
38
|
+
|
39
|
+
def user
|
40
|
+
user_hash['entry']
|
41
|
+
end
|
42
|
+
|
43
|
+
def user_hash
|
44
|
+
@user_hash ||= MultiJson.decode(@access_token.get("http://gdata.youtube.com/feeds/api/users/default?alt=json").body)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
OmniAuth.config.add_camelization 'youtube', 'YouTube'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "omniauth-youtube/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "omniauth-youtube"
|
7
|
+
gem.version = Omniauth::YouTube::VERSION
|
8
|
+
gem.authors = ["Benjamin Fritsch"]
|
9
|
+
gem.email = ["ben@lomography.com"]
|
10
|
+
gem.homepage = "https://github.com/lomography/omniauth-youtube"
|
11
|
+
gem.description = %q{OmniAuth strategy for YouTube}
|
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,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-youtube
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 15
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: "1.0"
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Benjamin Fritsch
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-11-30 00:00:00 -08:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: omniauth-oauth
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 15
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 0
|
32
|
+
version: "1.0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description: OmniAuth strategy for YouTube
|
36
|
+
email:
|
37
|
+
- ben@lomography.com
|
38
|
+
executables: []
|
39
|
+
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files: []
|
43
|
+
|
44
|
+
files:
|
45
|
+
- .gitignore
|
46
|
+
- README.md
|
47
|
+
- lib/omniauth-youtube.rb
|
48
|
+
- lib/omniauth-youtube/version.rb
|
49
|
+
- lib/omniauth/strategies/youtube.rb
|
50
|
+
- omniauth-youtube.gemspec
|
51
|
+
has_rdoc: true
|
52
|
+
homepage: https://github.com/lomography/omniauth-youtube
|
53
|
+
licenses: []
|
54
|
+
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
hash: 3
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
version: "0"
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 23
|
75
|
+
segments:
|
76
|
+
- 1
|
77
|
+
- 3
|
78
|
+
- 6
|
79
|
+
version: 1.3.6
|
80
|
+
requirements: []
|
81
|
+
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 1.6.2
|
84
|
+
signing_key:
|
85
|
+
specification_version: 3
|
86
|
+
summary: OmniAuth strategy for YouTube
|
87
|
+
test_files: []
|
88
|
+
|