omniauth-dailycred 0.0.1 → 0.0.2

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/README.md CHANGED
@@ -17,97 +17,96 @@ Or install it yourself as:
17
17
  ## Usage
18
18
 
19
19
  bash
20
- ~~~
21
- rails g controller sessions
22
- rails g model user provider:string uid:string email:string
23
- rake db:migrate
24
- touch app/views/sessions/hello.html.erb
25
- touch config/initializers/omniauth.rb
26
- rm public/index.html
27
- ~~~
20
+
21
+ rails g controller sessions
22
+ rails g model user provider:string uid:string email:string
23
+ rake db:migrate
24
+ touch app/views/sessions/hello.html.erb
25
+ touch config/initializers/omniauth.rb
26
+ rm public/index.html
27
+
28
28
 
29
29
  gemfile
30
- ~~~
31
- gem 'omniauth'
32
- gem 'omniauth-oauth2'
33
- gem 'omniauth-dailycred'
34
- ~~~
30
+
31
+ gem 'omniauth'
32
+ gem 'omniauth-oauth2'
33
+ gem 'omniauth-dailycred'
35
34
 
36
35
  config/initializers/omniauth.rb
37
- ~~~
38
- Rails.application.config.middleware.use OmniAuth::Builder do
39
- provider 'dailycred', YOUR_APP_KEY, YOUR_SECRET_KEY
40
- end
41
- ~~~
36
+
37
+ Rails.application.config.middleware.use OmniAuth::Builder do
38
+ provider 'dailycred', YOUR_APP_KEY, YOUR_SECRET_KEY
39
+ end
40
+
42
41
 
43
42
  routes.rb (make sure you delete the file /public/index.html)
44
- ~~~
45
- match "/auth/:provider/callback" => "sessions#create"
46
- match "/signout" => "sessions#destroy", :as => :signout
47
- root :to => "sessions#hello"
48
- ~~~
43
+
44
+ match "/auth/:provider/callback" => "sessions#create"
45
+ match "/signout" => "sessions#destroy", :as => :signout
46
+ root :to => "sessions#hello"
47
+
49
48
 
50
49
  sessions_controller.rb
51
- ~~~
52
- def create
53
- auth = request.env["omniauth.auth"]
54
- user = User.find_by_provider_and_uid(auth["provider"], auth["uid"]) || User.create_with_omniauth(auth)
55
- session[:user_id] = user.id
56
- redirect_to root_url, :notice => "Signed in!"
57
- end
58
-
59
- def destroy
60
- session[:user_id] = nil
61
- redirect_to root_url, :notice => "Signed out!"
62
- end
63
-
64
- def hello
65
-
66
- end
67
- ~~~
50
+
51
+ def create
52
+ auth = request.env["omniauth.auth"]
53
+ user = User.find_by_provider_and_uid(auth["provider"], auth["uid"]) || User.create_with_omniauth(auth)
54
+ session[:user_id] = user.id
55
+ redirect_to root_url, :notice => "Signed in!"
56
+ end
57
+
58
+ def destroy
59
+ session[:user_id] = nil
60
+ redirect_to root_url, :notice => "Signed out!"
61
+ end
62
+
63
+ def hello
64
+
65
+ end
66
+
68
67
 
69
68
  models/user.rb
70
- ~~~
71
- def self.create_with_omniauth(auth)
72
- create! do |user|
73
- user.provider = auth["provider"]
74
- user.uid = auth["uid"]
75
- user.name = auth["info"]["name"]
76
- end
77
- end
78
- ~~~
69
+
70
+ def self.create_with_omniauth(auth)
71
+ create! do |user|
72
+ user.provider = auth["provider"]
73
+ user.uid = auth["uid"]
74
+ user.name = auth["info"]["name"]
75
+ end
76
+ end
77
+
79
78
 
80
79
  application_controller.rb
81
- ~~~
82
- helper_method :current_user
83
80
 
84
- private
81
+ helper_method :current_user
82
+
83
+ private
84
+
85
+ def current_user
86
+ @current_user ||= User.find(session[:user_id]) if session[:user_id]
87
+ end
85
88
 
86
- def current_user
87
- @current_user ||= User.find(session[:user_id]) if session[:user_id]
88
- end
89
- ~~~
90
89
 
91
90
  app/views/sessions/hello.html.erb
92
- ~~~
93
- <% if current_user %>
94
- Welcome <%= current_user.email %>!
95
- <%= link_to "Sign Out", signout_path %>
96
- <% else %>
97
- <%= link_to "Sign in", "/auth/dailycred" %>
98
- <% end %>
99
- ~~~
91
+
92
+ <% if current_user %>
93
+ Welcome <%= current_user.email %>!
94
+ <%= link_to "Sign Out", signout_path %>
95
+ <% else %>
96
+ <%= link_to "Sign in", "/auth/dailycred" %>
97
+ <% end %>
98
+
100
99
 
101
100
  ## SSL Error
102
101
 
103
102
  You may get an error such as the following:
104
103
 
105
- Faraday::Error::ConnectionFailed (SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed):
104
+ Faraday::Error::ConnectionFailed (SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed):
106
105
 
107
106
  If that is the case, consider following fixes explained [here](https://github.com/technoweenie/faraday/wiki/Setting-up-SSL-certificates). If that doesn't work, consider adding the following line:
108
- ~~~
109
- OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
110
- ~~~
107
+
108
+ OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
109
+
111
110
  to the top of config/initializers/omniauth.rb
112
111
 
113
112
  ## Contributing
@@ -3,7 +3,7 @@ source 'http://rubygems.org'
3
3
  gem 'rails', '3.1.1'
4
4
  gem 'omniauth'
5
5
  gem 'omniauth-oauth2'
6
- gem 'omniauth-dailycred'
6
+ gem 'omniauth-dailycred', :path => "../"
7
7
  gem 'faraday'
8
8
 
9
9
  # Bundle edge Rails instead:
@@ -3,3 +3,5 @@ require File.expand_path('../application', __FILE__)
3
3
 
4
4
  # Initialize the rails application
5
5
  Example::Application.initialize!
6
+
7
+
@@ -1,4 +1,3 @@
1
- OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
2
1
  Rails.application.config.middleware.use OmniAuth::Builder do
3
- provider 'dailycred', '9dbbaebe-bb11-44ef-bbdd-5e58645fab30', 'd987fc65-1097-43b6-9342-5e6efbbe558a-3428de34-a734-428b-9a19-d6af6c9eab50', {:client_options => {:ssl => {:ca_path => "/opt/local/etc/openssl/certs"}}}
2
+ provider 'dailycred', '9dbbaebe-bb11-44ef-bbdd-5e58645fab30', 'd987fc65-1097-43b6-9342-5e6efbbe558a-3428de34-a734-428b-9a19-d6af6c9eab50', {:client_options => {:ssl => {:ca_file => '/opt/local/share/curl/curl-ca-bundle.crt'}}}
4
3
  end
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Dailycred
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -1,5 +1,6 @@
1
1
  require 'omniauth-oauth2'
2
2
  require 'faraday'
3
+ require 'net/https'
3
4
  require 'json'
4
5
 
5
6
  module OmniAuth
@@ -8,7 +9,7 @@ module OmniAuth
8
9
  option :client_options, {
9
10
  :site => 'https://www.dailycred.com',
10
11
  :authorize_url => '/oauth/authorize',
11
- :token_url => '/oauth/api/token.json'
12
+ :token_url => '/oauth/access_token'
12
13
  }
13
14
 
14
15
  uid { user['id'] }
@@ -23,13 +24,12 @@ module OmniAuth
23
24
 
24
25
  private
25
26
  def user
26
- conn = Faraday.new(:url => 'https://www.dailycred.com') do |faraday|
27
- faraday.request :url_encoded # form-encode POST params
28
- faraday.response :logger # log requests to STDOUT
29
- faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
30
- end
31
-
32
- response = conn.post '/oauth/api/me.json', {:access_token => access_token.token}
27
+ connection = Faraday::Connection.new 'https://www.dailycred.com', :ssl => {
28
+ :ca_file => "/opt/local/share/curl/curl-ca-bundle.crt"
29
+ }
30
+ response = connection.get("/graph/me.json?access_token=#{access_token.token}")
31
+ p response.body
32
+ p JSON.parse(response.body)
33
33
  json = JSON.parse(response.body)
34
34
  duser = {}
35
35
  duser['email'] = json['email']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-dailycred
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-13 00:00:00.000000000 Z
12
+ date: 2012-08-02 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: descript
15
15
  email: