Skip to content

Commit 55fa46a

Browse files
committed
Fix requiring of oauth2
The changes in #83 (which were released in v4.1.0) moved the `OauthClient` class (which uses the `oauth2` gem) from the Rails applications into the `rpi_auth` gem. At that point the `oauth2` gem was made a direct dependency of `rpi_auth` and the direct dependency on `oauth2` was removed from the Rails applications. I _think_ this meant that the `oauth2` gem was no longer being required automatically. And, although individual files in the `oauth2` gem were being required from individual files in `rpi_auth`, this meant that not all of the files in `oauth2` were being required. In particular, the `lib/oauth2.rb` file which defines the top-level `OAuth2` module and the `OAuth2.config` method were no longer being required. This led to exceptions like this one [1] in `experience-cs` when `RpiAuth::OauthClient#refresh_credentials` was called: NoMethodError: undefined method 'config' for module OAuth2 This commit changes the require statements to just require `oauth2` which in turn requires all the relevant files [2] in the `oauth2` gem. The require statement in `spec/rpi_auth/oauth_client_spec.rb` is unnecessary, because it's automatically loading `RpiAuth::OauthClient` which in turn loads `oauth2`. This should mean we no longer see exceptions like the one above. [1]: https://raspberrypifoundation.sentry.io/issues/6590882516?project=4508953237651456 [2]: https://gitlab.com/oauth-xx/oauth2/-/blob/v2.0.9/lib/oauth2.rb?ref_type=tags#L11-23
1 parent 19a41f0 commit 55fa46a

File tree

4 files changed

+3
-5
lines changed

4 files changed

+3
-5
lines changed

lib/rpi_auth/controllers/auto_refreshing_token.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
require 'oauth2/error'
3+
require 'oauth2'
44

55
module RpiAuth
66
module Controllers

lib/rpi_auth/oauth_client.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# frozen_string_literal: true
22

3-
require 'oauth2/client'
4-
require 'oauth2/access_token'
3+
require 'oauth2'
54

65
module RpiAuth
76
class OauthClient

spec/dummy/spec/requests/refresh_credentials_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
require 'spec_helper'
44

5-
require 'oauth2/error'
5+
require 'oauth2'
66

77
RSpec.describe 'Refreshing the auth token', type: :request do
88
include ActiveSupport::Testing::TimeHelpers

spec/rpi_auth/oauth_client_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# frozen_string_literal: true
22

33
require 'spec_helper'
4-
require 'oauth2'
54

65
RSpec.describe RpiAuth::OauthClient do
76
include ActiveSupport::Testing::TimeHelpers

0 commit comments

Comments
 (0)