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

[FEAT]: Support refreshtokens in OAuth flow #2731

Closed
1 task done
Kencdk opened this issue Jun 28, 2023 · 2 comments · Fixed by #2749
Closed
1 task done

[FEAT]: Support refreshtokens in OAuth flow #2731

Kencdk opened this issue Jun 28, 2023 · 2 comments · Fixed by #2749
Labels
Type: Feature New feature or request

Comments

@Kencdk
Copy link
Contributor

Kencdk commented Jun 28, 2023

Describe the need

While the library currently supports getting access tokens from an OAuth callback, the resulting object doesn't include the refresh token, which allows an application to get a new access token for the user, without having to go through the entire OAuth flow again.

Additionally, the OAuthClient doesn't support a way to get an access token from a refresh token.

The refresh token is returned in the original request to get an access token.
https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-user-access-token-for-a-github-app
https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/refreshing-user-access-tokens

Proposal:
Add RefreshToken as a property on Octokit/Models/Response/OauthToken.cs
Add RefreshToken as a property on Octokit/Models/Request/OauthTokenRequest.cs

If a OauthTokenRequest contains a RefreshToken but the AuthToken is null only the refresh_token property should be added to the request body due to the null check in RequestParameters.cs::ToParametersDictionary()

SDK Version

No response

API Version

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Kencdk Kencdk added Status: Triage This is being looked at and prioritized Type: Feature New feature or request labels Jun 28, 2023
@Kencdk
Copy link
Contributor Author

Kencdk commented Jun 28, 2023

if the proposal is accepted, I'll gladly implement it :)

@kfcampbell kfcampbell added Priority: Normal and removed Status: Triage This is being looked at and prioritized labels Jun 28, 2023
@kfcampbell
Copy link
Member

@Kencdk that seems reasonable to me! PRs are always appreciated.

Kencdk added a commit to Kencdk/octokit.net that referenced this issue Jul 18, 2023
Kencdk added a commit to Kencdk/octokit.net that referenced this issue Jul 18, 2023
kfcampbell added a commit that referenced this issue Jul 27, 2023
* Support refreshtokens in OAuth flow
Fixes #2731

* Added summary to OauthToken.cs constructors

* Mark deprecation of non-refreshToken constructor for OauthToken

* Remove unnecessary comment

---------

Co-authored-by: Keegan Campbell <me@kfcampbell.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature New feature or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants