omniauth-mailup 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -20,7 +20,7 @@ use OmniAuth::Builder do
20
20
  end
21
21
  ```
22
22
 
23
- In Rails, you'll want to add to the middleware stack:
23
+ In Rails, you'll want to add to the middleware stack (`config/initializers/omniauth.rb`):
24
24
 
25
25
  ```ruby
26
26
  Rails.application.config.middleware.use OmniAuth::Builder do
@@ -35,18 +35,32 @@ Here's an example _Authentication Hash_ available in `request.env['omniauth.auth
35
35
  ```ruby
36
36
  {
37
37
  :provider => 'mailup',
38
+ :uid => '10',
39
+ :info => {
40
+ :company => 'ACME, Inc.',
41
+ :nickname => 'm12345',
42
+ :is_trial => true
43
+ },
38
44
  :credentials => {
39
- :token => 'adsf456lkj758klfdsg' # OAuth 2.0 access_token. Store and use to authenticate API requests.
40
- }
45
+ :token => 'adsf456lkj758klfdsg5634kl', # OAuth 2.0 access_token.
46
+ :refresh_token => '6l5k37hl345656lh342345lh', # OAuth 2.0 refresh_token.
47
+ :expires => true,
48
+ :expires_at => 1369866442
49
+ },
50
+ :extra => {...}
41
51
  }
42
52
  ```
43
53
 
44
- ## License
54
+ ## Example
45
55
 
46
- Copyright (c) 2013 by Brian Getting and MailUp Inc.
56
+ An example Sinatra app is provided in `example/config.ru`. Simply follow these instructions:
47
57
 
48
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
58
+ ```
59
+ cd example
60
+ bundle
61
+ rackup config.ru
62
+ ```
49
63
 
50
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
64
+ You can then view the app in your browser at `localhost:9292`.
51
65
 
52
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
66
+ Please note that in order to authenticate with MailUp you will need to tunnel your local app using a service like [PageKite](http://pagekite.net) (recommended) or [Localtunnel](http://progrium.com/localtunnel/).
data/example/config.ru CHANGED
@@ -18,8 +18,7 @@ class App < Sinatra::Base
18
18
 
19
19
  get '/auth/:provider/callback' do
20
20
  content_type 'text/plain'
21
- token = request.env['omniauth.auth']['credentials']['token']
22
- "Access token is #{token}".inspect rescue "No data"
21
+ "AuthHash: #{request.env['omniauth.auth']}".inspect rescue "No data"
23
22
  end
24
23
 
25
24
  get '/auth/failure' do
@@ -1,5 +1,6 @@
1
1
  require 'omniauth-oauth2'
2
2
  require 'multi_json'
3
+ require 'multi_xml'
3
4
 
4
5
  module OmniAuth
5
6
  module Strategies
@@ -14,22 +15,27 @@ module OmniAuth
14
15
  }
15
16
 
16
17
  # TODO: Do we need this?
17
- #option :provider_ignores_state, true
18
-
19
- uid { raw_info["id"] }
18
+ option :provider_ignores_state, true
20
19
 
20
+ # AuthHash data for Omniauth
21
+ uid { raw_info["UID"] } # TODO: Need uid from MailUp
22
+
21
23
  info do
22
24
  {
23
- :email => raw_info["email"]
24
- # TODO: Whatever other info we want to return
25
+ :company => raw_info["Company"],
26
+ :nickname => raw_info["Username"],
27
+ :is_trial => raw_info["IsTrial"]
25
28
  }
26
29
  end
27
-
30
+
31
+ # Get more information about the user.
28
32
  def raw_info
29
- @raw_info ||= access_token.get('/API/v1/Console/User/Info.json').parsed
33
+ req = access_token.get('/API/v1/Rest/ConsoleService.svc/Console/Authentication/Info')
34
+ @raw_info ||= MultiXml.parse(req.body)["ConsoleCurrentAuthenticatedUserInfo"]
30
35
  end
31
36
  end
32
37
  end
33
38
  end
34
39
 
40
+ # Make sure that 'mailup' camelizes properly to 'MailUp'.
35
41
  OmniAuth.config.add_camelization 'mailup', 'MailUp'
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module MailUp
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -18,6 +18,8 @@ Gem::Specification.new do |gem|
18
18
  gem.require_paths = ["lib"]
19
19
 
20
20
  gem.add_runtime_dependency 'omniauth-oauth2', '~> 1.1.0'
21
+ gem.add_runtime_dependency 'multi_json', '~> 1.7.3'
22
+ gem.add_runtime_dependency 'multi_xml', '~> 0.5.3'
21
23
 
22
24
  gem.add_development_dependency "rspec"
23
25
  gem.add_development_dependency "rake"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-mailup
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: 2013-05-15 00:00:00.000000000 Z
12
+ date: 2013-05-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: omniauth-oauth2
@@ -27,6 +27,38 @@ dependencies:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  version: 1.1.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: multi_json
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 1.7.3
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.7.3
46
+ - !ruby/object:Gem::Dependency
47
+ name: multi_xml
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.5.3
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.5.3
30
62
  - !ruby/object:Gem::Dependency
31
63
  name: rspec
32
64
  requirement: !ruby/object:Gem::Requirement