Sitelet https://github.com/vertica/vertica-python/pull/549
Skip to content

Allowing for refresh token rotation during token refresh request - #549

Merged
sitingren merged 2 commits into
vertica:masterfrom
DMickens:Support-for-OTDS-refresh-token-flow
Feb 21, 2024
Merged

sitingren merged 2 commits into
vertica:masterfrom
DMickens:Support-for-OTDS-refresh-token-flow

Conversation

@DMickens

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor

@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
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