Skip to content

enhance: update credentials framework for OAuth support #305

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

Merged
merged 6 commits into from
Jun 24, 2024

Conversation

g-linville
Copy link
Member

@g-linville g-linville commented Apr 30, 2024

This adds support for expiration and refresh tokens to the credential framework. All of these changes are backwards compatible with existing credentials, though new credentials will be stored in a slightly different format.

Notable changes:

  • An expiration time for the credential will be saved if the cred tool provides that field. Once the credential is expired, the next time it is requested, the credential tool will be run again.
  • A refresh token for the credential will be saved if the cred tool provides that field. This is useful in certain OAuth situations for requesting a new token without user interaction.
  • gptscript cred output looks a little nicer and displays more information.

@g-linville g-linville force-pushed the credential-expiration branch 3 times, most recently from d36a144 to 6443c29 Compare June 19, 2024 17:55
@g-linville g-linville marked this pull request as ready for review June 19, 2024 18:27
@g-linville g-linville changed the title enhance: update credentials framework for oauth support enhance: update credentials framework for OAuth support Jun 19, 2024
Signed-off-by: Grant Linville <[email protected]>
Signed-off-by: Grant Linville <[email protected]>
Signed-off-by: Grant Linville <[email protected]>
@g-linville g-linville force-pushed the credential-expiration branch from b922d5e to ec67482 Compare June 22, 2024 17:16
Copy link
Member

@njhale njhale left a comment

Choose a reason for hiding this comment

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

Left a few nits, but otherwise LGTM!

sort.Strings(envVars)
_, _ = fmt.Fprintf(w, "%s\t%s\t%s\n", cred.Context, cred.ToolName, strings.Join(envVars, ", "))
}
_, _ = w.Write([]byte("CONTEXT\tCREDENTIAL\tEXPIRES IN\tENV\n"))
Copy link
Member

Choose a reason for hiding this comment

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

nit: does the linter complain if you omit _, _ =?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep. golangci-lint complains, and GoLand underlines it

Copy link
Contributor

@StrongMonkey StrongMonkey left a comment

Choose a reason for hiding this comment

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

LGTM except one small question

Signed-off-by: Grant Linville <[email protected]>
@g-linville g-linville merged commit 60da900 into gptscript-ai:main Jun 24, 2024
8 checks passed
@g-linville g-linville deleted the credential-expiration branch June 24, 2024 18:10
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.

3 participants