Merge branch 'bugfix/issue-289' into 'master'

Fix OAuthSession#load returning when all inst_vars are assigned

See merge request os85/httpx!321
This commit is contained in:
HoneyryderChuck 2024-02-01 11:19:35 +00:00
commit 2f513526d3

View File

@ -60,16 +60,17 @@ module HTTPX
end
def load(http)
return unless @token_endpoint && @token_endpoint_auth_method && @grant_type && @scope
return if @token_endpoint && @token_endpoint_auth_method && @grant_type && @scope
metadata = http.get("#{issuer}/.well-known/oauth-authorization-server").raise_for_status.json
metadata = http.get("#{@issuer}/.well-known/oauth-authorization-server").raise_for_status.json
@token_endpoint = metadata["token_endpoint"]
@scope = metadata["scopes_supported"]
@grant_type = Array(metadata["grant_types_supported"]).find { |gr| SUPPORTED_GRANT_TYPES.include?(gr) }
@token_endpoint_auth_method = Array(metadata["token_endpoint_auth_methods_supported"]).find do |am|
@token_endpoint ||= metadata["token_endpoint"]
@scope ||= metadata["scopes_supported"]
@grant_type ||= Array(metadata["grant_types_supported"]).find { |gr| SUPPORTED_GRANT_TYPES.include?(gr) }
@token_endpoint_auth_method ||= Array(metadata["token_endpoint_auth_methods_supported"]).find do |am|
SUPPORTED_AUTH_METHODS.include?(am)
end
nil
end
def merge(other)