feat: add --no-auth flag to api command for unauthenticated requests#566
feat: add --no-auth flag to api command for unauthenticated requests#566WilliamBergamin wants to merge 2 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #566 +/- ##
==========================================
+ Coverage 71.66% 71.67% +0.01%
==========================================
Files 226 226
Lines 19115 19140 +25
==========================================
+ Hits 13699 13719 +20
- Misses 4209 4215 +6
+ Partials 1207 1206 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
zimeg
left a comment
There was a problem hiding this comment.
@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 👾
There was a problem hiding this comment.
| 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!
|
@zimeg thanks for this awesome feedback 💯 I opted to add the "No app" option to the app selection prompt to allow users to submit a request without an app token 🚀 But I think we need to keep some sort of I did think of renaming it to |
zimeg
left a comment
There was a problem hiding this comment.
@WilliamBergamin Clean implementation! This puts things in great direction for building configurations of a selection! Thanks for improving this alongside feedback suggestions 🧰 ✨
| // ErrNoAppSelected is returned when the user selects "No app" in the prompt | ||
| var ErrNoAppSelected = fmt.Errorf("no app selected") |
There was a problem hiding this comment.
🚧 suggestion: Can we import this from errors.go instead?
| // AppSelectOption configures optional behavior of AppSelectPrompt | ||
| type AppSelectOption func(*appSelectConfig) | ||
|
|
||
| type appSelectConfig struct { | ||
| includeNoApp bool | ||
| } |
There was a problem hiding this comment.
🌟 praise: Excited for what this pattern unlocks in customizations!
Changelog
Allow the
apicommand to send unauthenticated requests when no token is available or when--no-authis specified.Summary
Some Slack API methods (e.g.
api.test,blocks.validate) don't require authentication. Previously, theapicommand always resolved a token and failed with an error if none was available, even when calling methods that don't need one.This PR makes two changes:
--no-authflag: skips token resolution entirely. Useful in scripts or CI where you want to avoid interactive prompts and explicitly signal that no auth is needed.The app selection prompt (shown in project directories) now includes a "No app" option, allowing users to opt out of authentication interactively.
--no-authcannot be combined with--tokenor--appflags.Preview
Testing
Notes
None
Requirements