omniauth-netatmo 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/.rspec +1 -0
- data/Gemfile +3 -0
- data/README.md +83 -0
- data/Rakefile +8 -0
- data/lib/omniauth-netatmo.rb +1 -0
- data/lib/omniauth/netatmo.rb +2 -0
- data/lib/omniauth/netatmo/version.rb +5 -0
- data/lib/omniauth/strategies/netatmo.rb +50 -0
- data/omniauth-netatmo.gemspec +25 -0
- data/spec/omniauth/strategies/netatmo_spec.rb +36 -0
- data/spec/spec_helper.rb +15 -0
- metadata +141 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 21f3fab1c77372a64b0b3238dd1279e7acf56185
|
4
|
+
data.tar.gz: 2cae5689a0eb9e1a429bbad3eb22c04806a92009
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fd8deab27e837bf66d69828bc70af7440e1dba224ff356b630af1db35cd3d8012b75438515ccc9c555a1d61beb05a9b77a72ac00eda57b7b648a7a6f8da62131
|
7
|
+
data.tar.gz: faabda16aef8ff547d4ac120f529b8d6ad6bb96b75c985eaeac1a93654c8e7aecda6ae98733d7ba3457ebf29fe67f64ee47494d1d58e5f8ca3eed73a81aa68af
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
# OmniAuth Netatmo [![Build Status](https://travis-ci.org/vincent-pochet/omniauth-netatmo.svg)](https://travis-ci.org/vincent-pochet/omniauth-netatmo)
|
2
|
+
|
3
|
+
This gem contains the [Natatmo](https://www.netatmo.com/) strategy for OmniAuth.
|
4
|
+
|
5
|
+
## Before You Begin
|
6
|
+
|
7
|
+
You should have already installed OmniAuth into your app; if not, read the [OmniAuth README](https://github.com/intridea/omniauth) to get started.
|
8
|
+
|
9
|
+
Now sign in into the [Netatmo developer area](https://dev.netatmo.com) and create an application.
|
10
|
+
|
11
|
+
## Using This Strategy
|
12
|
+
|
13
|
+
First start by adding this gem to your Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'omniauth-netatmo'
|
17
|
+
```
|
18
|
+
|
19
|
+
Next, tell OmniAuth about this provider. For a Rails app, your `config/initializers/omniauth.rb` file should look like this:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
23
|
+
provider :netatmo, "API_KEY", "API_SECRET"
|
24
|
+
end
|
25
|
+
```
|
26
|
+
|
27
|
+
Replace `"API_KEY"` and `"API_SECRET"` with the appropriate values you obtained [earlier](https://dev.netatmo.com).
|
28
|
+
|
29
|
+
## Authentication Hash
|
30
|
+
An example auth hash available in `request.env['omniauth.auth']`:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
{
|
34
|
+
:provider => "netatmo",
|
35
|
+
:uid => "123456",
|
36
|
+
:info => {
|
37
|
+
:email => 'foobar@test.com'
|
38
|
+
},
|
39
|
+
:credentials => {
|
40
|
+
:token => "a1b2c3d4...", # The OAuth 2.0 access token
|
41
|
+
:secret => "abcdef1234"
|
42
|
+
},
|
43
|
+
:extra => {
|
44
|
+
:access_token => "", # An OAuth::AccessToken object
|
45
|
+
:raw_info => {
|
46
|
+
"status" => "ok",
|
47
|
+
"body" => {
|
48
|
+
"_id" => "547c1f431e77599d1a7e25dd",
|
49
|
+
"administrative" => {
|
50
|
+
"country" => "FR",
|
51
|
+
"reg_locale" => "fr",
|
52
|
+
"lang" => "fr",
|
53
|
+
"unit" => 0,
|
54
|
+
"windunit" => 0,
|
55
|
+
"pressureunit" => 0,
|
56
|
+
"feel_like_algo" => 0
|
57
|
+
},
|
58
|
+
"date_creation" => {
|
59
|
+
"sec" => 1417420611,
|
60
|
+
"usec" => 0
|
61
|
+
},
|
62
|
+
"mail" => "vincent@ruby42.com"
|
63
|
+
},
|
64
|
+
"time_exec" => 0.084523916244507,
|
65
|
+
"time_server" => 1417421657
|
66
|
+
}
|
67
|
+
}
|
68
|
+
}
|
69
|
+
```
|
70
|
+
|
71
|
+
## Supported Rubies
|
72
|
+
|
73
|
+
OmniAuth Netatmo is tested under 1.9.3, 2.0.0, 2.1.0, JRuby, and Rubinius.
|
74
|
+
|
75
|
+
## License
|
76
|
+
|
77
|
+
Copyright (c) 2011 by Vincent Pochet
|
78
|
+
|
79
|
+
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:
|
80
|
+
|
81
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
82
|
+
|
83
|
+
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.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'omniauth/netatmo'
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Netatmo < OmniAuth::Strategies::OAuth2
|
6
|
+
|
7
|
+
option :client_options, {
|
8
|
+
:site => 'http://api.netatmo.com',
|
9
|
+
:authorize_url => 'http://api.netatmo.net/oauth2/authorize',
|
10
|
+
:token_url => 'http://api.netatmo.net/oauth2/token'
|
11
|
+
}
|
12
|
+
|
13
|
+
option :token_params, {
|
14
|
+
:parse => :query
|
15
|
+
}
|
16
|
+
|
17
|
+
option :access_token_options, {
|
18
|
+
:param_name => 'access_token'
|
19
|
+
}
|
20
|
+
|
21
|
+
def request_phase
|
22
|
+
super
|
23
|
+
end
|
24
|
+
|
25
|
+
def authorize_params
|
26
|
+
super.tap do |params|
|
27
|
+
%w[scope grant_type].each do |v|
|
28
|
+
if request.params[v]
|
29
|
+
params[v.to_sym] = request..params[v]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
uid { raw_info['_id'] }
|
36
|
+
|
37
|
+
info do
|
38
|
+
{ :email => raw_info['email'] }
|
39
|
+
end
|
40
|
+
|
41
|
+
extra do
|
42
|
+
{ :raw_info => raw_info }
|
43
|
+
end
|
44
|
+
|
45
|
+
def raw_info
|
46
|
+
@raw_info ||= access_token.get('/api/getuser').parsed || {}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "omniauth/netatmo/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "omniauth-netatmo"
|
7
|
+
s.version = OmniAuth::Netatmo::VERSION
|
8
|
+
s.authors = ["Vincent Pochet"]
|
9
|
+
s.email = ["vincent@ruby42.com"]
|
10
|
+
s.homepage = "https://github.com/vincent-pochet/omniauth-netatmo"
|
11
|
+
s.summary = "Netatmo OAuth2 Strategy for OmniAuth"
|
12
|
+
s.license = "MIT"
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
|
19
|
+
s.add_dependency 'omniauth', '~> 1.0'
|
20
|
+
s.add_dependency 'omniauth-oauth2', '~> 1.1'
|
21
|
+
s.add_development_dependency 'rspec', '~> 2.7'
|
22
|
+
s.add_development_dependency 'rack-test'
|
23
|
+
s.add_development_dependency 'simplecov'
|
24
|
+
s.add_development_dependency 'webmock'
|
25
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::Strategies::Netatmo do
|
4
|
+
let(:access_token) { stub('AccessToken', :options => {}) }
|
5
|
+
let(:parsed_response) { stub('ParsedResponse') }
|
6
|
+
let(:response) { stub('Response', :parsed => parsed_response) }
|
7
|
+
|
8
|
+
subject do
|
9
|
+
OmniAuth::Strategies::Netatmo.new({})
|
10
|
+
end
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
subject.stub!(:access_token).and_return(access_token)
|
14
|
+
end
|
15
|
+
|
16
|
+
context "client options" do
|
17
|
+
it 'should have correct site' do
|
18
|
+
subject.options.client_options.site.should eq("http://api.netatmo.com")
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should have correct authorize url' do
|
22
|
+
subject.options.client_options.authorize_url.should eq('http://api.netatmo.net/oauth2/authorize')
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should have correct token url' do
|
26
|
+
subject.options.client_options.token_url.should eq('http://api.netatmo.net/oauth2/token')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "#raw_info" do
|
31
|
+
it "should use relative paths" do
|
32
|
+
access_token.should_receive(:get).with('/api/getuser').and_return(response)
|
33
|
+
subject.raw_info.should eq(parsed_response)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
$:.unshift File.expand_path('..', __FILE__)
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
require 'simplecov'
|
4
|
+
SimpleCov.start
|
5
|
+
require 'rspec'
|
6
|
+
require 'rack/test'
|
7
|
+
require 'webmock/rspec'
|
8
|
+
require 'omniauth'
|
9
|
+
require 'omniauth-netatmo'
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.include WebMock::API
|
13
|
+
config.include Rack::Test::Methods
|
14
|
+
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-netatmo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Vincent Pochet
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: omniauth
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: omniauth-oauth2
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rack-test
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: webmock
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- vincent@ruby42.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- Gemfile
|
107
|
+
- README.md
|
108
|
+
- Rakefile
|
109
|
+
- lib/omniauth-netatmo.rb
|
110
|
+
- lib/omniauth/netatmo.rb
|
111
|
+
- lib/omniauth/netatmo/version.rb
|
112
|
+
- lib/omniauth/strategies/netatmo.rb
|
113
|
+
- omniauth-netatmo.gemspec
|
114
|
+
- spec/omniauth/strategies/netatmo_spec.rb
|
115
|
+
- spec/spec_helper.rb
|
116
|
+
homepage: https://github.com/vincent-pochet/omniauth-netatmo
|
117
|
+
licenses:
|
118
|
+
- MIT
|
119
|
+
metadata: {}
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 2.4.3
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: Netatmo OAuth2 Strategy for OmniAuth
|
140
|
+
test_files: []
|
141
|
+
has_rdoc:
|