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

support reading "expires_in" when the API passes the value as string #23921

Merged
merged 3 commits into from
Mar 10, 2023

Conversation

leo-schick
Copy link
Contributor

What

I was dealing with the OAuth2 implementation of trustpilot.com and they pass the expires_in OAuth parameter as string and not as integer.

This results then in the following error:

bad operand type for abs(): 'str'

With this PR, we would cast the value from expires_in into an integer.

How

using int(..) around the value. This then supports both use cases: string and integer values

🚨 User Impact 🚨

No breaking changes.

@leo-schick leo-schick requested a review from a team as a code owner March 9, 2023 21:37
@octavia-squidington-iii octavia-squidington-iii added CDK Connector Development Kit community labels Mar 9, 2023
Copy link
Contributor

@sherifnada sherifnada left a comment

Choose a reason for hiding this comment

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

@leo-schick thanks for your contribution! We actually just received this same contribution yesterday here: https://github.com/airbytehq/airbyte/pull/20301/files and it will be released very soon. So you should be able to receive the fix today

@sherifnada
Copy link
Contributor

@leo-schick actually come to think of it, I see you have one additional bugfix not included in that PR.

I've just merged that PR to master. Could you pull master into your branch, add a test case for the extra file you modified not modified in that PR, and I'll merge your contribution as well?

@sherifnada
Copy link
Contributor

@leo-schick please pull master and lmk when it's ready for a review

@leo-schick leo-schick force-pushed the fix-oauth-stringed-expires-in branch from 6f027ec to a8045a4 Compare March 10, 2023 07:25
@leo-schick
Copy link
Contributor Author

@sherifnada done

@@ -95,7 +95,7 @@ def refresh_access_token(self) -> Tuple[str, int]:
)
response.raise_for_status()
response_json = response.json()
return response_json["access_token"], response_json["expires_in"]
return response_json["access_token"], int(response_json["expires_in"])
Copy link
Contributor

Choose a reason for hiding this comment

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

@leo-schick could you add a unit test for this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sherifnada I extended the existing unit tests with some assert checks

@sherifnada sherifnada merged commit 0995542 into airbytehq:master Mar 10, 2023
@leo-schick leo-schick deleted the fix-oauth-stringed-expires-in branch March 13, 2023 13:53
danielduckworth pushed a commit to danielduckworth/airbyte that referenced this pull request Mar 13, 2023
adriennevermorel pushed a commit to adriennevermorel/airbyte that referenced this pull request Mar 17, 2023
erohmensing pushed a commit that referenced this pull request Mar 22, 2023
erohmensing pushed a commit that referenced this pull request Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CDK Connector Development Kit community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants