Skip to content

feat: add --no-auth flag to api command for unauthenticated requests#566

Open
WilliamBergamin wants to merge 1 commit into
mainfrom
no-auth-for-api-command
Open

feat: add --no-auth flag to api command for unauthenticated requests#566
WilliamBergamin wants to merge 1 commit into
mainfrom
no-auth-for-api-command

Conversation

@WilliamBergamin
Copy link
Copy Markdown
Contributor

Changelog

Add --no-auth flag to the api command, allowing users to call Slack API methods that don't require authentication.

Summary

Some Slack API methods don't require authentication. Previously, the api command always resolved a token, failing if none was available, even when calling methods that don't need one. This prevents users from using publicly accessible endpoints.

This PR adds a --no-auth flag that skips token resolution entirely and sends the request without a token.

Preview

Screenshot 2026-05-29 at 1 30 50 PM

Testing

slack api blocks.validate --no-auth blocks='[{"type":"section","text":{"type":"mrkdwn","text":"Hello"}}]'
slack api api.test --no-auth

Notes

None

Requirements

@WilliamBergamin WilliamBergamin added this to the Next Release milestone May 29, 2026
@WilliamBergamin WilliamBergamin self-assigned this May 29, 2026
@WilliamBergamin WilliamBergamin requested a review from a team as a code owner May 29, 2026 17:40
@WilliamBergamin WilliamBergamin added enhancement M-T: A feature request for new functionality semver:minor Use on pull requests to describe the release version increment labels May 29, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 29, 2026

Codecov Report

❌ Patch coverage is 89.47368% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.72%. Comparing base (c693443) to head (ac3ebc5).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cmd/api/api.go 89.47% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #566      +/-   ##
==========================================
+ Coverage   71.66%   71.72%   +0.06%     
==========================================
  Files         226      226              
  Lines       19115    19128      +13     
==========================================
+ Hits        13699    13720      +21     
+ Misses       4209     4205       -4     
+ Partials     1207     1203       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@zimeg zimeg left a comment

Choose a reason for hiding this comment

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

@WilliamBergamin Super nice unlocks this is bringing 🔓 ✨

I'm leaving a comment on an adjacent approach we can consider? Not against having --no-auth also but think it could pair with a new app select prompt option "no app" within projects 🎲 so details on this flag or methods needing it isn't needed in scripts otherwise 👾

Comment thread cmd/api/api.go
Comment on lines 288 to 290
return "", slackerror.New(slackerror.ErrNotAuthed).
WithMessage("no token found").
WithRemediation("Provide a token with --token, --app, or set SLACK_BOT_TOKEN")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
return "", nil

🔮 thought: We might want to accept no token as valid input without requiring to know which flag is needed. I realize multiple cases exist for gathering tokens and we could use --help outputs toward this. The API response I think is meaningful too:

{
    "ok": false,
    "error": "not_authed"
}

🌛 suggestion: Might adding a "no app" option to app selection perhaps support having a --no-auth flag?

  Select an app
    A0B78JUQG4U devrelsandbox T02A074M3U3
    A0B78KLUSFN tinyspek E06LPMFSSTU
+ ❱ No app

🐮 ramble: In scripts a missing --token flag might have similar results and I hope the earlier error and documentation has details toward remediation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement M-T: A feature request for new functionality semver:minor Use on pull requests to describe the release version increment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants