-
Notifications
You must be signed in to change notification settings - Fork 188
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
PDE-5319 feat(cli): invoke auth start
subcommand
#872
Conversation
invoke auth
subcommandinvoke auth start
subcommand
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested custom and oauth2, and they work! Nice job! Excited for this.
I have a pair of non-blocking comments
} | ||
|
||
async startBasicAuth(authFields) { | ||
if (this.nonInteractive) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does basic auth need interactive mode?
Is it for censoring the password?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically we want to make sure the CLI doesn't ask interactive questions in non-interactive mode (nonInteractive === true
). For basic
auth, the only thing that auth start
does is ask for username and password interactively. auth start
with basic
auth doesn't really make sense in non-interactive mode, which is why we throw an error here.
Does that make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case you're asking why we're not allowing this non-interactive use case for basic
auth:
echo '{"username":"user","password":"secret"}' | zapier invoke auth start
We could but I thought that would be useless, since it'd be easier for the user to edit .env
or append the auth fields to .env
:
echo 'authData_username=user' >> .env
echo 'authData_password=secret' >> .env
}); | ||
|
||
endSpinner(); | ||
startSpinner('Opening browser to authorize'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got stuck at authorizing bc of bad params, I reckon it's hard to kill this process if the browser request errors?
Do you think it's valuable to set a timer for the code promise or provide 'ctrl/cmd + c' to abort helper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the partner server encounters an error and doesn't redirect to localhost, we won’t be able to detect the error. I prefer not to use a timer for this. I think the best approach would be to let the user know they can press CTRL-C to exit if an error occurs. I've added this in 9929e9c.
CTRL-C already works on my machine. Does it work on yours? @standielpls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it does, thank you for adding the hint text
Changes:
zapier invoke auth start
subcommand--non-interactive
flag tozapier invoke
commandzapier invoke
betteropen
package added in this PR requires Node.js 18mock-fs
along the way because the old version wasn't working on Node.js 20 😠The
auth start
subcommand works with the following authentication types:oauth2
basic
custom
session
Authentication types
oauth1
anddigest
are rare, so I'm leaving them out of this PR for now.For
oauth2
,auth start
does following:CLIENT_ID
andCLIENT_SECRET
are defined in.env
. If not, prompt for them.authentication.oauth2Config.authorizeUrl
code
parameter in the redirect request and callauthentication.oauth2Config.getAccessToken
to get the access token.env
For
basic
andcustom
,auth start
simply prompts for the auth fields.For
session
,auth start
prompts for the required auth fields and callsauthentication.sessionConfig.perform
to get the computed auth field(s) (e.g. a session key).