lib/rdstation/authentication.rb in rdstation-ruby-client-2.1.0 vs lib/rdstation/authentication.rb in rdstation-ruby-client-2.2.0
- old
+ new
@@ -5,13 +5,14 @@
AUTH_TOKEN_URL = 'https://api.rd.services/auth/token'.freeze
DEFAULT_HEADERS = { 'Content-Type' => 'application/json' }.freeze
REVOKE_URL = 'https://api.rd.services/auth/revoke'.freeze
- def initialize(client_id, client_secret)
- @client_id = client_id
- @client_secret = client_secret
+ def initialize(client_id = nil, client_secret = nil)
+ warn_deprecation if client_id || client_secret
+ @client_id = client_id || RDStation.configuration&.client_id
+ @client_secret = client_secret || RDStation.configuration&.client_secret
end
#
# param redirect_url
# URL that the user will be redirected
@@ -80,8 +81,12 @@
self.class.post(
AUTH_TOKEN_URL,
body: body.to_json,
headers: DEFAULT_HEADERS
)
+ end
+
+ def warn_deprecation
+ warn "DEPRECATION WARNING: Providing client_id and client_secret directly to RDStation::Authentication.new is deprecated and will be removed in future versions. Use RDStation.configure instead."
end
end
end