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

Improvement python delta-sharing client: convert expires_in as string to int, if returned as string #628

Merged

Conversation

moderakh
Copy link
Collaborator

@moderakh moderakh commented Dec 29, 2024

TL;DR: This PR enhances the OAuth client to support cases where the expires_in field in the token response is returned as a string instead of an integer. While the OAuth 2.0 specification mandates that expires_in should be an integer RFC 6749 Section 4.1.4, some OAuth servers return it as a string, leading to potential compatibility issues.

Certain OAuth implementations deviate from the standard and return expires_in as a string, e.g.:

{
  "access_token": "example-token",
  "expires_in": "3600",  // Returned as a string
  "token_type": "Bearer"
}

This causes failures when the client expects the field to always be an integer.

Solution

This PR updates the token parsing logic to:
1. Check the type of the expires_in field.
2. Convert the value to an integer if it is provided as a string.
3. Maintain backward compatibility with the standard integer format.

@moderakh moderakh requested a review from chakankardb December 29, 2024 21:09
@moderakh moderakh changed the title Handle expires_in as string or int in OAuth token exchange Bugfix: Handle expires_in as string or int in OAuth token exchange Dec 29, 2024
@moderakh moderakh requested a review from linzhou-db December 29, 2024 21:16
@moderakh moderakh changed the title Bugfix: Handle expires_in as string or int in OAuth token exchange Bugfix: Handle expires_in as string if returned as string Dec 30, 2024
@moderakh moderakh changed the title Bugfix: Handle expires_in as string if returned as string Bugfix: convert expires_in as string to int, if returned as string Dec 30, 2024
@moderakh moderakh changed the title Bugfix: convert expires_in as string to int, if returned as string Bugfix: convert expires_in as string to int, if returned as string in python client Dec 30, 2024
@moderakh moderakh changed the title Bugfix: convert expires_in as string to int, if returned as string in python client Bugfix python delta-sharing client: convert expires_in as string to int, if returned as string Dec 30, 2024
@moderakh moderakh changed the title Bugfix python delta-sharing client: convert expires_in as string to int, if returned as string Improvement python delta-sharing client: convert expires_in as string to int, if returned as string Dec 30, 2024
Copy link
Collaborator

@charlenelyu-db charlenelyu-db left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@moderakh moderakh merged commit b72872d into delta-io:main Dec 30, 2024
5 checks passed
moderakh added a commit to moderakh/delta-sharing that referenced this pull request Dec 30, 2024
… to int, if returned as string (delta-io#628)

**TL;DR:** This PR enhances the OAuth client to support cases where the expires_in field in the token response is returned as a string instead of an integer. While the OAuth 2.0 specification mandates that expires_in should be an integer  [RFC 6749 Section 4.1.4](https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.4), some OAuth servers return it as a string, leading to potential compatibility issues.

Certain OAuth implementations deviate from the standard and return expires_in as a string, e.g.:

```
{
  "access_token": "example-token",
  "expires_in": "3600",  // Returned as a string
  "token_type": "Bearer"
}
```
This causes failures when the client expects the field to always be an integer.

Solution

This PR updates the token parsing logic to:
	1.	Check the type of the expires_in field.
	2.	Convert the value to an integer if it is provided as a string.
	3.	Maintain backward compatibility with the standard integer format.
moderakh added a commit that referenced this pull request Dec 30, 2024
… to int, if returned as string (#628) (#630)

This PR cherry picks #628 to python-branch-1.3

**TL;DR:** This PR enhances the OAuth client to support cases where the expires_in field in the token response is returned as a string instead of an integer. While the OAuth 2.0 specification mandates that expires_in should be an integer  [RFC 6749 Section 4.1.4](https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.4), some OAuth servers return it as a string, leading to potential compatibility issues.

Certain OAuth implementations deviate from the standard and return expires_in as a string, e.g.:

```
{
  "access_token": "example-token",
  "expires_in": "3600",  // Returned as a string
  "token_type": "Bearer"
}
```
This causes failures when the client expects the field to always be an integer.

Solution

This PR updates the token parsing logic to:
	1.	Check the type of the expires_in field.
	2.	Convert the value to an integer if it is provided as a string.
	3.	Maintain backward compatibility with the standard integer format.
moderakh added a commit that referenced this pull request Dec 31, 2024
…to int, if returned as string (#631)

TL;DR This PR improves oauth-client in spark-client to support parsing expires_in as string similar to the changes for the python client: #628


Detail:
This PR enhances the OAuth client to support cases where the expires_in field in the token response is returned as a string instead of an integer. While the OAuth 2.0 specification mandates that expires_in should be an integer [RFC 6749 Section 4.1.4](https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.4), some OAuth servers return it as a string, leading to potential compatibility issues.

Certain OAuth implementations deviate from the standard and return expires_in as a string, e.g.:

```
{
  "access_token": "example-token",
  "expires_in": "3600",  // Returned as a string
  "token_type": "Bearer"
}
```
This causes failures when the client expects the field to always be an integer.

Solution

This PR updates the token parsing logic to:
1. Check the type of the expires_in field.
2. Convert the value to an integer if it is provided as a string.
3. Maintain backward compatibility with the standard integer format.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants