From 9fe216e8d2f59e4375a4b7c766844366f7166a0a Mon Sep 17 00:00:00 2001 From: Marcin Hagmajer Date: Fri, 8 Apr 2022 13:49:21 +0200 Subject: [PATCH] fix: Support OAuth with multiple redirect URIs (#302) --- src/commands/login.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/commands/login.js b/src/commands/login.js index 101d56f5..ce1be4ac 100644 --- a/src/commands/login.js +++ b/src/commands/login.js @@ -21,6 +21,7 @@ class OAuthLoginCommand extends BoxCommand { const { flags } = this.parse(OAuthLoginCommand); const environmentsObj = await this.getEnvironments(); const port = flags.port; + const redirectUri = `http://localhost:${port}/callback`; this.info( chalk`{cyan If you are not using the quickstart guide to set up ({underline https://developer.box.com/guides/tooling/cli/quick-start/}) then go to the Box Developer console ({underline https://cloud.app.box.com/developers/console}) and:}` @@ -30,7 +31,7 @@ class OAuthLoginCommand extends BoxCommand { chalk`{cyan 1. Select an application with OAuth user authentication method. Create a new Custom App if needed.}` ); this.info( - chalk`{cyan 2. Click on the Configuration tab and set the Redirect URI to: {italic http://localhost:${port}/callback}. Click outside the input field.}` + chalk`{cyan 2. Click on the Configuration tab and set the Redirect URI to: {italic ${redirectUri}}. Click outside the input field.}` ); this.info(chalk`{cyan 3. Click on {bold Save Changes}.}`); @@ -130,6 +131,7 @@ class OAuthLoginCommand extends BoxCommand { const authorizeUrl = sdk.getAuthorizeURL({ response_type: 'code', state, + redirect_uri: redirectUri, }); open(authorizeUrl);