Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to OAuth2 authentication JSON output #48

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/signet/oauth_2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ def self.generate_authorization_uri(authorization_uri, parameters={})
end
parsed_uri = Addressable::URI.parse(authorization_uri).dup
query_values = parsed_uri.query_values || {}
query_values.keys.each do |key|
query_values[(key.to_sym rescue key) || key] = query_values.delete(key)
end
query_values = query_values.merge(parameters)
parsed_uri.query_values = query_values
return parsed_uri.normalize.to_s
Expand Down
8 changes: 5 additions & 3 deletions lib/signet/oauth_2/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def token_credential_uri=(new_token_credential_uri)
@token_credential_uri = coerce_uri(new_token_credential_uri)
end

# Addressable expects URIs formatted as hashes to come in with symbols as keys.
# Addressable expects URIs formatted as hashes to come in with symbols as keys.
# Returns nil implicitly for the nil case.
def coerce_uri(incoming_uri)
if incoming_uri.is_a? Hash
Expand Down Expand Up @@ -738,7 +738,7 @@ def issued_at
# @param [String] new_issued_at
# The access token issuance time.
def issued_at=(new_issued_at)
@issued_at = new_issued_at
@issued_at = Time.at(new_issued_at) rescue nil
end

##
Expand Down Expand Up @@ -864,6 +864,8 @@ def to_json
'audience' => self.audience,
'person' => self.person,
'expiry' => self.expiry,
'expires_in' => self.expires_in,
'issued_at' => self.issued_at.to_i,
'signing_key' => self.signing_key,
'refresh_token' => self.refresh_token,
'access_token' => self.access_token,
Expand Down Expand Up @@ -1130,7 +1132,7 @@ def uri_is_postmessage?(uri)
def uri_is_oob?(uri)
return uri.to_s == 'urn:ietf:wg:oauth:2.0:oob' || uri.to_s == 'oob'
end

# Convert all keys in this hash (nested) to symbols for uniform retrieval
def recursive_hash_normalize_keys(val)
if val.is_a? Hash
Expand Down