omniauth-dexcom-oauth2 1.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1cffb36ad65628fe22edc1ba794386bae611c9bd6e776d7a23401704f07e57b5
4
+ data.tar.gz: cce6048f144ceec18d64cbbbfed814857f791453fbca99334bf77564388a6161
5
+ SHA512:
6
+ metadata.gz: 871e615b2e8d3aed2ae16f20228dd2a14e1d020e9a9708436f33d83afa4b3eb09c9a879215dcce7d60d946968402b07746b7edde998281b627f91a2ee7e01822
7
+ data.tar.gz: 7b0d54c931f85e33ab91ca217046938eab72a6519f38cb301ef0237042fdd8b9d62fa8af3ebba992e695a4c98b0b301c8fb6cb87a4f5ec52cdc457436b5e00d4
data/.gitignore ADDED
@@ -0,0 +1,19 @@
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
18
+ .ruby-gemset
19
+ .ruby-version
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2
4
+ - 2.3
5
+ - 2.4
6
+ - 2.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-dexcom-oauth2.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2022 Eric Shelley
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # OmniAuth Dexcom OAuth2 Strategy
2
+
3
+ [![Build Status](https://travis-ci.org/bartimaeus/omniauth-dexcom-oauth2.svg?branch=master)](https://travis-ci.org/bartimaeus/omniauth-dexcom-oauth2)
4
+ [![Gem Version](https://badge.fury.io/rb/omniauth-dexcom-oauth2.svg)](https://badge.fury.io/rb/omniauth-dexcom-oauth2)
5
+
6
+ A Dexcom OAuth2 strategy for OmniAuth.
7
+
8
+ For more details, read the [Dexcom documentation](https://developer.dexcom.com/authentication)
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ gem 'omniauth-dexcom-oauth2'
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install omniauth-dexcom-oauth2
23
+
24
+ ## Usage
25
+
26
+ Register your application with dexcom to receive an API key: https://developer.dexcom.com/
27
+
28
+ This is an example that you might put into a Rails initializer at `config/initializers/omniauth.rb`:
29
+
30
+ ```ruby
31
+ Rails.application.config.middleware.use OmniAuth::Builder do
32
+ provider :dexcom, ENV['DEXCOM_CLIENT_ID'], ENV['DEXCOM_CLIENT_SECRET'], :scope => 'offline_access'
33
+ end
34
+ ```
35
+
36
+ You can now access the OmniAuth Dexcom OAuth2 URL: `/auth/dexcom`.
37
+
38
+ ## Granting Member Permissions to Your Application
39
+
40
+ With the Dexcom API, you have the ability to specify which permissions you want users to grant your application.
41
+ For more details, read the [Dexcom documentation](https://developer.dexcom.com/scopes-access)
42
+
43
+ The five scopes of data access:
44
+
45
+ - Estimated Blood Glucose Levels
46
+ - Calibration Data
47
+ - Events Entry Data
48
+ - Device Details
49
+ - CGM Statistics
50
+
51
+ You can configure the scope option:
52
+
53
+ ```ruby
54
+ provider :dexcom, ENV['DEXCOM_CLIENT_ID'], ENV['DEXCOM_CLIENT_SECRET'], :scope => 'offline_access'
55
+ ```
56
+
57
+ ## Contributing
58
+
59
+ 1. Fork it
60
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
61
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
62
+ 4. Push to the branch (`git push origin my-new-feature`)
63
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/example/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'sinatra'
4
+ gem 'omniauth-dexcom-oauth2'
data/example/config.ru ADDED
@@ -0,0 +1,31 @@
1
+ # Sample app for Dexcom OAuth2 Strategy
2
+ # Make sure to setup the ENV variables DEXCOM_CLIENT_ID and DEXCOM_CLIENT_SECRET
3
+ # Run with "bundle exec rackup"
4
+
5
+ require 'bundler/setup'
6
+ require 'sinatra/base'
7
+ require 'omniauth-dexcom-oauth2'
8
+
9
+ class App < Sinatra::Base
10
+ get '/' do
11
+ redirect '/auth/dexcom'
12
+ end
13
+
14
+ get '/auth/:provider/callback' do
15
+ content_type 'application/json'
16
+ MultiJson.encode(request.env['omniauth.auth'])
17
+ end
18
+
19
+ get '/auth/failure' do
20
+ content_type 'application/json'
21
+ MultiJson.encode(request.env)
22
+ end
23
+ end
24
+
25
+ use Rack::Session::Cookie, :secret => 'change_me'
26
+
27
+ use OmniAuth::Builder do
28
+ provider :dexcom, ENV['DEXCOM_CLIENT_ID'], ENV['DEXCOM_CLIENT_SECRET'], scope: 'user:read'
29
+ end
30
+
31
+ run App.new
@@ -0,0 +1,38 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Dexcom < OmniAuth::Strategies::OAuth2
6
+ option :name, 'dexcom'
7
+
8
+ option :client_options, {
9
+ :site => 'https://api.dexcom.com',
10
+ :authorize_url => 'https://api.dexcom.com/v2/oauth2/login',
11
+ :token_url => 'https://api.dexcom.com/v2/oauth2/token'
12
+ }
13
+
14
+ option :scope, 'offline_access'
15
+
16
+ info do
17
+ {
18
+ 'auth' => oauth2_access_token
19
+ }
20
+ end
21
+
22
+ def callback_url
23
+ full_host + script_name + callback_path
24
+ end
25
+
26
+ alias :oauth2_access_token :access_token
27
+
28
+ def access_token
29
+ ::OAuth2::AccessToken.new(client, oauth2_access_token.token, {
30
+ :expires_in => oauth2_access_token.expires_in,
31
+ :expires_at => oauth2_access_token.expires_at
32
+ })
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ OmniAuth.config.add_camelization 'dexcom', 'Dexcom'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module DexcomOauth2
3
+ VERSION = '1.0.0'
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require "omniauth-dexcom-oauth2/version"
2
+ require "omniauth/strategies/dexcom"
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth-dexcom-oauth2/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "omniauth-dexcom-oauth2"
8
+ gem.version = OmniAuth::DexcomOauth2::VERSION
9
+ gem.authors = ["Eric Shelley"]
10
+ gem.email = ["eric@webdesignbakery.com"]
11
+ gem.description = %q{Dexcom OAuth2 strategy for OmniAuth.}
12
+ gem.summary = %q{Dexcom OAuth2 strategy for OmniAuth.}
13
+ gem.homepage = "https://github.com/bartimaeus/omniauth-dexcom-oauth2"
14
+ gem.license = "MIT"
15
+
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.require_paths = ["lib"]
20
+
21
+ gem.add_runtime_dependency 'omniauth-oauth2', '~> 1.2'
22
+
23
+ gem.add_development_dependency 'bundler', '>= 1.16', '< 3.0'
24
+ gem.add_development_dependency 'rake', '~> 12.3'
25
+
26
+ gem.add_development_dependency 'rspec', '~> 3.6'
27
+ gem.add_development_dependency 'simplecov', '~> 0.16'
28
+ end
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+ require 'omniauth-dexcom-oauth2'
3
+
4
+ describe OmniAuth::Strategies::Dexcom do
5
+ subject { OmniAuth::Strategies::Dexcom.new(nil) }
6
+
7
+ it 'adds camelization for itself' do
8
+ expect(OmniAuth::Utils.camelize('dexcom')).to eq('Dexcom')
9
+ end
10
+
11
+ describe '#client' do
12
+ it 'has correct Dexcom site' do
13
+ expect(subject.client.site).to eq('https://api.dexcom.com')
14
+ end
15
+
16
+ it 'has correct `authorize_url`' do
17
+ expect(subject.client.options[:authorize_url]).to eq('https://api.dexcom.com/v2/oauth2/login')
18
+ end
19
+
20
+ it 'has correct `token_url`' do
21
+ expect(subject.client.options[:token_url]).to eq('https://api.dexcom.com/v2/oauth2/token')
22
+ end
23
+ end
24
+
25
+ describe '#info' do
26
+ let(:access_token) { instance_double OAuth2::AccessToken }
27
+ let(:parsed_response) {}
28
+
29
+ before :each do
30
+ allow(subject).to receive(:access_token).and_return access_token
31
+ end
32
+
33
+ it 'returns parsed responses using access token' do
34
+ expect(subject.info).to have_key 'auth'
35
+ end
36
+ end
37
+
38
+ describe '#access_token' do
39
+ let(:expires_in) { 3600 }
40
+ let(:expires_at) { 946688400 }
41
+ let(:token) { 'token' }
42
+ let(:access_token) do
43
+ instance_double OAuth2::AccessToken, :expires_in => expires_in,
44
+ :expires_at => expires_at, :token => token
45
+ end
46
+
47
+ before :each do
48
+ allow(subject).to receive(:oauth2_access_token).and_return access_token
49
+ end
50
+
51
+ specify { expect(subject.access_token.expires_in).to eq expires_in }
52
+ specify { expect(subject.access_token.expires_at).to eq expires_at }
53
+ end
54
+
55
+ describe '#authorize_params' do
56
+ describe 'scope' do
57
+ before :each do
58
+ allow(subject).to receive(:session).and_return({})
59
+ end
60
+
61
+ it 'sets default scope' do
62
+ expect(subject.authorize_params['scope']).to eq('offline_access')
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,19 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
4
+ # This file was generated by the `rspec --init` command. Conventionally, all
5
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
6
+ # Require this file using `require "spec_helper"` to ensure that it is only
7
+ # loaded once.
8
+ #
9
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
10
+ RSpec.configure do |config|
11
+ config.run_all_when_everything_filtered = true
12
+ config.filter_run :focus
13
+
14
+ # Run specs in random order to surface order dependencies. If you find an
15
+ # order dependency and want to debug it, you can fix the order by providing
16
+ # the seed, which is printed after each run.
17
+ # --seed 1234
18
+ config.order = 'random'
19
+ end
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-dexcom-oauth2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Eric Shelley
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-08-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth-oauth2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '1.16'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '3.0'
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '1.16'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '3.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '12.3'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '12.3'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rspec
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '3.6'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '3.6'
75
+ - !ruby/object:Gem::Dependency
76
+ name: simplecov
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '0.16'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '0.16'
89
+ description: Dexcom OAuth2 strategy for OmniAuth.
90
+ email:
91
+ - eric@webdesignbakery.com
92
+ executables: []
93
+ extensions: []
94
+ extra_rdoc_files: []
95
+ files:
96
+ - ".gitignore"
97
+ - ".rspec"
98
+ - ".travis.yml"
99
+ - Gemfile
100
+ - LICENSE.txt
101
+ - README.md
102
+ - Rakefile
103
+ - example/Gemfile
104
+ - example/config.ru
105
+ - lib/omniauth-dexcom-oauth2.rb
106
+ - lib/omniauth-dexcom-oauth2/version.rb
107
+ - lib/omniauth/strategies/dexcom.rb
108
+ - omniauth-dexcom-oauth2.gemspec
109
+ - spec/omniauth/strategies/dexcom_spec.rb
110
+ - spec/spec_helper.rb
111
+ homepage: https://github.com/bartimaeus/omniauth-dexcom-oauth2
112
+ licenses:
113
+ - MIT
114
+ metadata: {}
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubygems_version: 3.2.20
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: Dexcom OAuth2 strategy for OmniAuth.
134
+ test_files:
135
+ - spec/omniauth/strategies/dexcom_spec.rb
136
+ - spec/spec_helper.rb