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

Allowing for refresh token rotation during token refresh request #549

Merged

Conversation

DMickens
Copy link
Contributor

Modifying 'get_access_token_using_refresh_token' to return both access and refresh tokens, which gets passed through 'do_token_refresh'.

The access token being returned is unchanged. The refresh token being returned is either the same value that is currently saved in the connection in the case that we are not using refresh token rotation. If we are using refresh token rotation, like with OTDS, then we receive a new refresh token every time we use one. This means we have to update what is saved on the connection so that we can get this refresh token programmatically in case we want to do token refresh again.

@DMickens
Copy link
Contributor Author

@sitingren either you can give this a review when you return and I can add tests and we can move forward like that, or if you would prefer I can just hand this off to you in it's current state and you can carry it to the finish line in whatever way you see fit. I'm good with either direction.

@sitingren
Copy link
Member

I assume there should be an API for client user to get the new refresh token?

@sitingren sitingren self-assigned this Feb 19, 2024
@DMickens
Copy link
Contributor Author

I assume there should be an API for client user to get the new refresh token?

I just added get_current_refresh_token to connection.py.

Test:
with vertica_python.connect(**conn_info) as conn:
cur = conn.cursor()

    cur.execute(f"SELECT 'connection {x}'")
    response = cur.fetchall()
    print(response)
    refresh_token = conn.get_current_refresh_token()

Results:
[['connection 0']]
[['connection 1']]
[['connection 2']]
[['connection 3']]
[['connection 4']]

Conclusion: Able to save and use new refresh token

@DMickens DMickens requested a review from sitingren February 21, 2024 00:09
@sitingren
Copy link
Member

@DMickens Thanks! I'll merge this PR and add more improvements (including update README) in a later PR.

@sitingren sitingren merged commit 422f265 into vertica:master Feb 21, 2024
8 checks passed
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