Skip to content

Commit

Permalink
ci failure fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bajajneha27 committed Aug 11, 2023
1 parent 463e0d5 commit d205c62
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
15 changes: 8 additions & 7 deletions lib/signet/oauth_2/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -843,8 +843,8 @@ def granted_scopes
# The scope of access the client is requesting. This may be
# expressed as either an Array of String objects or as a
# space-delimited String.
def granted_scopes= new_granted_scope
@granted_scopes = new_granted_scope&.split
def granted_scopes= new_granted_scopes
@granted_scopes = new_granted_scopes&.split
end

##
Expand Down Expand Up @@ -1046,12 +1046,13 @@ def fetch_access_token options = {}
content_type = response.header[:content_type]
end

parsed_response = ::Signet::OAuth2.parse_credentials body, content_type if status == 200
parsed_response["granted_scopes"] = parsed_response.delete("scope")
return parsed_response

message = " Server message:\n#{response.body.to_s.strip}" unless body.to_s.strip.empty?
if [400, 401, 403].include? status

if status == 200
parsed_response = ::Signet::OAuth2.parse_credentials body, content_type
parsed_response["granted_scopes"] = parsed_response.delete("scope") if parsed_response
return parsed_response
elsif [400, 401, 403].include? status
message = "Authorization failed.#{message}"
raise ::Signet::AuthorizationError.new message, response: response
elsif status.to_s[0] == "5"
Expand Down
6 changes: 3 additions & 3 deletions spec/signet/oauth_2/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def build_form_encoded_response payload
end

it "should allow to set granted scopes" do
@client.granted_scopes = ["granted_scopes1 granted_scopes2"]
@client.granted_scopes = "granted_scopes1 granted_scopes2"
expect(@client.granted_scopes).to eq ["granted_scopes1", "granted_scopes2"]
end

Expand Down Expand Up @@ -381,14 +381,14 @@ def build_form_encoded_response payload
refresh_token: "54321",
:expires_in => 3600,
:issued_at => issued_at,
:granted_scopes => ["scope1"]
:granted_scopes => "scope1"
)
expect(@client.access_token).to eq "12345"
expect(@client.refresh_token).to eq "54321"
expect(@client.expires_in).to eq 3600
expect(@client.issued_at).to eq issued_at
expect(@client).to_not be_expired
expect(@client).to eq ["scope1"]
expect(@client.granted_scopes).to eq ["scope1"]
end

it "should handle expires as equivalent to expires_in" do
Expand Down

0 comments on commit d205c62

Please sign in to comment.