Skip to content

Commit 5a18f40

Browse files
Merge pull request #154 from codeflash-ai/revert-132-hosted-oauth-local-handoff
Revert "Support hosted OAuth callback handoff for all connectors"
2 parents add98ad + c792e17 commit 5a18f40

26 files changed

Lines changed: 443 additions & 5686 deletions

apps/desktop/src-tauri/src/main.rs

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10195,15 +10195,14 @@ fn connect_notion_with_broker(state_root: PathBuf, open_browser: bool) -> Result
1019510195
let start = broker
1019610196
.start(&NotionOAuthBrokerStart {
1019710197
redirect_uri: redirect_uri.clone(),
10198-
hosted_callback_handoff: true,
1019910198
})
1020010199
.map_err(|error| format!("Could not start Notion OAuth broker flow: {error}"))?;
1020110200
let authorization_url = start.normalized_authorization_url();
1020210201
set_notion_login_link(authorization_url.clone());
1020310202
let authorization = run_local_oauth_authorization(
1020410203
"Notion",
1020510204
&authorization_url,
10206-
start.local_redirect_uri(),
10205+
&start.redirect_uri,
1020710206
&start.state,
1020810207
!open_browser,
1020910208
true,
@@ -10213,15 +10212,14 @@ fn connect_notion_with_broker(state_root: PathBuf, open_browser: bool) -> Result
1021310212
let previous_connection = connection_id
1021410213
.as_ref()
1021510214
.and_then(|connection_id| store.get_connection(connection_id).ok().flatten());
10216-
let exchange_redirect_uri = start.exchange_redirect_uri().to_string();
1021710215
let options = BrokerOAuthConnectOptions {
1021810216
connection_id,
1021910217
broker_url,
1022010218
client_id: start.client_id,
1022110219
session: start.session,
1022210220
state: start.state,
1022310221
code: authorization.code,
10224-
redirect_uri: exchange_redirect_uri,
10222+
redirect_uri: start.redirect_uri,
1022510223
};
1022610224

1022710225
let report =
@@ -10263,27 +10261,25 @@ fn connect_google_docs_with_broker(
1026310261
.start(&OAuthBrokerStart {
1026410262
connector: GOOGLE_DOCS_CONNECTOR_ID.to_string(),
1026510263
redirect_uri,
10266-
hosted_callback_handoff: true,
1026710264
})
1026810265
.map_err(|error| format!("Could not start Google Docs OAuth broker flow: {error}"))?;
1026910266
let authorization = run_local_oauth_authorization(
1027010267
"Google Docs",
1027110268
&start.authorization_url,
10272-
start.local_redirect_uri(),
10269+
&start.redirect_uri,
1027310270
&start.state,
1027410271
!open_browser,
1027510272
true,
1027610273
)
1027710274
.map_err(|error| error.message)?;
10278-
let exchange_redirect_uri = start.exchange_redirect_uri().to_string();
1027910275
let options = GoogleDocsBrokerOAuthConnectOptions {
1028010276
connection_id: None,
1028110277
broker_url,
1028210278
client_id: start.client_id,
1028310279
session: start.session,
1028410280
state: start.state,
1028510281
code: authorization.code,
10286-
redirect_uri: exchange_redirect_uri,
10282+
redirect_uri: start.redirect_uri,
1028710283
};
1028810284

1028910285
let report =
@@ -10317,27 +10313,25 @@ fn connect_google_calendar_with_broker(
1031710313
.start(&OAuthBrokerStart {
1031810314
connector: GOOGLE_CALENDAR_CONNECTOR_ID.to_string(),
1031910315
redirect_uri,
10320-
hosted_callback_handoff: true,
1032110316
})
1032210317
.map_err(|error| format!("Could not start Google Calendar OAuth broker flow: {error}"))?;
1032310318
let authorization = run_local_oauth_authorization(
1032410319
"Google Calendar",
1032510320
&start.authorization_url,
10326-
start.local_redirect_uri(),
10321+
&start.redirect_uri,
1032710322
&start.state,
1032810323
!open_browser,
1032910324
true,
1033010325
)
1033110326
.map_err(|error| error.message)?;
10332-
let exchange_redirect_uri = start.exchange_redirect_uri().to_string();
1033310327
let options = GoogleCalendarBrokerOAuthConnectOptions {
1033410328
connection_id: Some(ConnectionId::new("google-calendar-default")),
1033510329
broker_url,
1033610330
client_id: start.client_id,
1033710331
session: start.session,
1033810332
state: start.state,
1033910333
code: authorization.code,
10340-
redirect_uri: exchange_redirect_uri,
10334+
redirect_uri: start.redirect_uri,
1034110335
};
1034210336

1034310337
let report = run_connect_google_calendar_broker_oauth(
@@ -10377,27 +10371,25 @@ fn connect_gmail_with_broker(state_root: PathBuf, open_browser: bool) -> Result<
1037710371
.start(&OAuthBrokerStart {
1037810372
connector: GMAIL_CONNECTOR_ID.to_string(),
1037910373
redirect_uri,
10380-
hosted_callback_handoff: true,
1038110374
})
1038210375
.map_err(|error| format!("Could not start Gmail OAuth broker flow: {error}"))?;
1038310376
let authorization = run_local_oauth_authorization(
1038410377
"Gmail",
1038510378
&start.authorization_url,
10386-
start.local_redirect_uri(),
10379+
&start.redirect_uri,
1038710380
&start.state,
1038810381
!open_browser,
1038910382
true,
1039010383
)
1039110384
.map_err(|error| error.message)?;
10392-
let exchange_redirect_uri = start.exchange_redirect_uri().to_string();
1039310385
let options = GmailBrokerOAuthConnectOptions {
1039410386
connection_id: None,
1039510387
broker_url,
1039610388
client_id: start.client_id,
1039710389
session: start.session,
1039810390
state: start.state,
1039910391
code: authorization.code,
10400-
redirect_uri: exchange_redirect_uri,
10392+
redirect_uri: start.redirect_uri,
1040110393
};
1040210394

1040310395
let report = run_connect_gmail_broker_oauth(&mut store, credentials.as_ref(), options, &broker)
@@ -10430,27 +10422,25 @@ fn connect_slack_with_broker(state_root: PathBuf, open_browser: bool) -> Result<
1043010422
.start(&OAuthBrokerStart {
1043110423
connector: SLACK_CONNECTOR_ID.to_string(),
1043210424
redirect_uri,
10433-
hosted_callback_handoff: true,
1043410425
})
1043510426
.map_err(|error| format!("Could not start Slack OAuth broker flow: {error}"))?;
1043610427
let authorization = run_local_oauth_authorization(
1043710428
"Slack",
1043810429
&start.authorization_url,
10439-
start.local_redirect_uri(),
10430+
&start.redirect_uri,
1044010431
&start.state,
1044110432
!open_browser,
1044210433
true,
1044310434
)
1044410435
.map_err(|error| error.message)?;
10445-
let exchange_redirect_uri = start.exchange_redirect_uri().to_string();
1044610436
let options = SlackBrokerOAuthConnectOptions {
1044710437
connection_id: None,
1044810438
broker_url,
1044910439
client_id: start.client_id,
1045010440
session: start.session,
1045110441
state: start.state,
1045210442
code: authorization.code,
10453-
redirect_uri: exchange_redirect_uri,
10443+
redirect_uri: start.redirect_uri,
1045410444
};
1045510445

1045610446
let report = run_connect_slack_broker_oauth(&mut store, credentials.as_ref(), options, &broker)

0 commit comments

Comments
 (0)