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

[Question][GitHub] App Refresh Token #8242

Open
endersonmenezes opened this issue Dec 17, 2024 · 8 comments
Open

[Question][GitHub] App Refresh Token #8242

endersonmenezes opened this issue Dec 17, 2024 · 8 comments
Labels
type/question This issue is a question

Comments

@endersonmenezes
Copy link

Question

I'm trying to develop a method to refresh the GitHub token when using GitHub Apps, I'm checking the files in the folder, but I haven't found much logic when a GetDynamicGitUrl is requested, I believe the logic could be here.

Screenshots

If applicable, add screenshots to help explain.

Additional context

I don't work directly with the tool, but I'm interested in the project and I want to be able to contribute with small things, but I'm still getting to grips with the product's logic, if anyone can help I'd be grateful.

@endersonmenezes endersonmenezes added the type/question This issue is a question label Dec 17, 2024
Copy link

dosubot bot commented Dec 17, 2024

Hello @endersonmenezes! I'm here to help you with any bugs, questions, or contributions you have in mind. Let's work on solving this together!

The GetDynamicGitUrl method is used to generate a new Git URL for a GitHub repository by replacing the access token in the provided repository URL with the token associated with a specific GitHub connection. However, it does not handle the logic for refreshing GitHub tokens [1].

For GitHub App authentication and token management, the current implementation uses a combination of access tokens and app keys. The GithubConn struct supports two authentication methods: AccessToken and AppKey. The AppKey method involves generating a JWT and using it to request an installation access token from GitHub, which is then used for API requests [2].

Unfortunately, there is no specific documentation or code in the repository that details the process of refreshing GitHub tokens for GitHub Apps, nor are there specific files or directories dedicated to this logic [2]. If you are looking to implement token refresh functionality, you might need to explore the GitHub API documentation for guidance on how to handle token refresh for GitHub Apps.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@endersonmenezes
Copy link
Author

@dosu If I put the logic to generate and verify the token inside the "PrepareApiClient" function, would it be valid? Or would it keep this fixed and continue to have problems with a repository that takes more than an hour to collect the data.

Copy link

dosubot bot commented Dec 17, 2024

Implementing token generation and verification logic directly within the PrepareApiClient function could lead to potential issues, especially for long-running operations. The PrepareApiClient function is designed to set up the initial state for API requests, such as preparing tokens for use. If you include token generation and verification logic here, it might not effectively handle token expiration during long data collection processes.

For operations that take more than an hour, you should consider implementing a mechanism to refresh tokens dynamically during the operation. This could involve checking the token's expiration time and requesting a new token when necessary, rather than relying solely on the initial setup in PrepareApiClient. This approach would help ensure that your API requests remain authenticated throughout the entire data collection process.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@endersonmenezes
Copy link
Author

@dosu Do you believe that implementing a method that tests the Token within the URL within GitExtractor would be a better approach? If so, where would you recommend?

Copy link

dosubot bot commented Dec 17, 2024

Implementing a method to test the token within the URL in the GitExtractor could be a viable approach to ensure that the token is valid before proceeding with operations. This would help in handling token expiration issues effectively.

A suitable place to implement this logic would be within the PrepareTaskData method of the GitExtractor. This method is responsible for preparing the task data, including handling the Git URL and appending user credentials if provided. You could add a step here to validate the token before proceeding with further operations. This would ensure that the token is checked and refreshed if necessary before any data collection begins [1].

Additionally, you might consider implementing a utility function that can be called to validate the token. This function could be reused in other parts of the code where token validation is necessary, promoting code reusability and maintainability.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@endersonmenezes
Copy link
Author

@dosu The commit edd7dc0 already introduces a method that uses a token for each task, so it doesn't seem necessary to change the task preparation but rather the task in execution.

Copy link

dosubot bot commented Dec 17, 2024

The commit edd7dc09740d171cbf14b2a5479b6bd154072f3e introduces a method that uses a token for each task, which suggests that the focus should be on managing tokens during task execution rather than during task preparation. To handle token expiration effectively during task execution, you might want to ensure that the token management logic dynamically refreshes or rotates tokens as needed throughout the task's lifecycle. This can be achieved by implementing or enhancing existing mechanisms that check and refresh tokens during the execution phase, ensuring that long-running tasks remain authenticated.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@endersonmenezes
Copy link
Author

Okay, I was able to look at the code more with a friend (@ClaudioMascaro ). Maybe it's necessary to do something in the ApiClient during the task execution time, but it would be something that I would check if it's a task coming from GitHub, I don't know to what extent this is an interesting design for the tool.

Could any maintainer discuss this further with us?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/question This issue is a question
Projects
None yet
Development

No branches or pull requests

1 participant