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: add support to use PATs instead of OAuth #361

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

thedadams
Copy link
Contributor

@thedadams thedadams commented Jan 22, 2025

Tools will now be able to specify, in their metadata, that their OAuth credential supports personal access tokens with the oauthPATSupported field being "true". If a tool does this, then the OAuth credential will prompt the user for a PAT instead of going through the OAuth flow.

This change includes this field on the GitHub and Atlassian tools.

Lastly, this change removes support for OAuth outside Obot. The OAuth credential tool will no longer look at the CLI config nor default to use the Gateway.

Issue: obot-platform/obot#1372

Tools will now be able to specify, in their metadata, that their OAuth
credential supports personal access tokens with the oauthPATSupported
field being "true". If a tool does this, then the OAuth credential will
prompt the user for a PAT instead of going through the OAuth flow.

This change includes this field on the GitHub and Atlassian tools.

Lastly, this change removes support for OAuth outside Obot. The OAuth
credential tool will no longer look at the CLI config nor default to use
the Gateway.

Signed-off-by: Donnie Adams <[email protected]>
@thedadams thedadams force-pushed the oauth-pat-token-support branch from ce01561 to 71f451d Compare January 22, 2025 16:01
oauth2/main.go Outdated
defer g.Close()

run, err := g.Run(context.Background(), "sys.prompt", gptscript.Options{
Input: fmt.Sprintf(`{"metadata": %s,"message":"Please enter your personal access token for %s.","fields":"Token","sensative": true}`, b, integration),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Input: fmt.Sprintf(`{"metadata": %s,"message":"Please enter your personal access token for %s.","fields":"Token","sensative": true}`, b, integration),
Input: fmt.Sprintf(`{"metadata": %s,"message":"Please enter your personal access token for %s.","fields":"Token","sensitive": true}`, b, integration),

If this typo exists on the gptscript end, then it should be fixed there too.

Signed-off-by: Donnie Adams <[email protected]>
@thedadams thedadams requested a review from g-linville January 22, 2025 19:54
if !slices.Contains(strings.Split(strings.ToLower(os.Getenv("GPTSCRIPT_OAUTH_PAT_INTEGRATIONS")), ","), strings.ToLower(integration)) {
fmt.Printf("All the following environment variables must be set: GPTSCRIPT_OAUTH_%s_AUTH_URL, GPTSCRIPT_OAUTH_%[1]s_REFRESH_URL, GPTSCRIPT_OAUTH_%[1]s_TOKEN_URL", normalizeForEnv(integration))
fmt.Printf("Or include %s in GPTSCRIPT_OAUTH_PAT_INTEGRATIONS to allow prompting for a personal access token\n", integration)
os.Exit(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: return nil for consistency?

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