omniauth-quizlet 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-quizlet.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/Readme.md ADDED
@@ -0,0 +1 @@
1
+ ### An omniauth strategy for [quizlet](www.quizlet.com)
@@ -0,0 +1,2 @@
1
+ require "omniauth-quizlet/version"
2
+ require 'omniauth/strategies/quizlet'
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Quizlet
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,52 @@
1
+ require 'omniauth-oauth2'
2
+ require 'base64'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Quizlet < OmniAuth::Strategies::OAuth2
7
+ DEFAULT_SCOPE = 'read'
8
+
9
+ option :client_options, {
10
+ :site => 'https://quizlet.com/',
11
+ :authorize_url => 'https://quizlet.com/authorize/',
12
+ :token_url => 'https://api.quizlet.com/oauth/token'
13
+ }
14
+
15
+ option :authorize_params, {
16
+ :response_type => 'code',
17
+ :scope => 'read',
18
+ :state => 'some_random_string'
19
+ }
20
+
21
+ extra do
22
+ raw_info
23
+ end
24
+
25
+ uid { raw_info['user_id'] }
26
+
27
+ def raw_info
28
+ access_token.options[:mode] = :header
29
+ encoded_auth = Base64.encode64("#{options.client_id}:#{options.client_secret}").strip
30
+ access_token.options[:header_format] = "Basic #{encoded_auth}"
31
+ access_token.options[:param_name] = :code
32
+ access_token.options[:headers] = {
33
+ 'grant_type' => 'authorization_code'
34
+ }
35
+ begin
36
+ ops = {
37
+ :headers => { 'grant_type'=>'authorization_code'},
38
+ :body => {
39
+ 'grant_type'=>'authorization_code',
40
+ 'code' => @request.params['code']
41
+ }
42
+ }
43
+ @raw_info ||= access_token.post(options.client_options['token_url'],ops).parsed
44
+ rescue Exception => e
45
+ Rails.logger.info e.inspect
46
+ end
47
+ end
48
+
49
+
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth-quizlet/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["dongbin.li"]
6
+ gem.email = ["mike.d.1984@gmail.com"]
7
+ gem.description = %q{quizlet omniauth strategy}
8
+ gem.summary = %q{quizlet omniauth strategy}
9
+ gem.homepage = ""
10
+
11
+ gem.rubyforge_project = "omniauth-quizlet"
12
+ gem.add_dependency 'omniauth', '~> 1.0.0.rc2'
13
+ gem.add_dependency 'omniauth-oauth2', '~> 1.0.0.rc2'
14
+
15
+
16
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ gem.files = `git ls-files`.split("\n")
18
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ gem.name = "omniauth-quizlet"
20
+ gem.require_paths = ["lib"]
21
+ gem.version = Omniauth::Quizlet::VERSION
22
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-quizlet
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - dongbin.li
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-16 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth
16
+ requirement: &2154176200 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.0.0.rc2
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2154176200
25
+ - !ruby/object:Gem::Dependency
26
+ name: omniauth-oauth2
27
+ requirement: &2154175700 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.0.rc2
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *2154175700
36
+ description: quizlet omniauth strategy
37
+ email:
38
+ - mike.d.1984@gmail.com
39
+ executables: []
40
+ extensions: []
41
+ extra_rdoc_files: []
42
+ files:
43
+ - .gitignore
44
+ - Gemfile
45
+ - Rakefile
46
+ - Readme.md
47
+ - lib/omniauth-quizlet.rb
48
+ - lib/omniauth-quizlet/version.rb
49
+ - lib/omniauth/strategies/quizlet.rb
50
+ - omniauth-quizlet.gemspec
51
+ homepage: ''
52
+ licenses: []
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubyforge_project: omniauth-quizlet
71
+ rubygems_version: 1.8.11
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: quizlet omniauth strategy
75
+ test_files: []
76
+ has_rdoc: