MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / oauth_callback

Function oauth_callback

crates/opencode-server/src/routes.rs:2379–2409  ·  view source on GitHub ↗
(
    State(state): State<Arc<ServerState>>,
    Path(id): Path<String>,
    Json(req): Json<OAuthCallbackRequest>,
)

Source from the content-addressed store, hash-verified

2377}
2378
2379async fn oauth_callback(
2380 State(state): State<Arc<ServerState>>,
2381 Path(id): Path<String>,
2382 Json(req): Json<OAuthCallbackRequest>,
2383) -> Result<Json<bool>> {
2384 let loader = get_plugin_loader()
2385 .ok_or_else(|| ApiError::NotFound("no plugin loader initialized".to_string()))?;
2386 ProviderAuth::new(state.auth_manager.clone())
2387 .callback(loader, &id, req.code.as_deref())
2388 .await
2389 .map_err(|e| ApiError::BadRequest(e.to_string()))?;
2390
2391 // Refresh auth loader state after callback and apply custom-fetch proxy changes immediately.
2392 if let Some(bridge) = loader.auth_bridge(&id).await {
2393 match bridge.load().await {
2394 Ok(load_result) => {
2395 crate::server::sync_custom_fetch_proxy(&id, bridge, load_result.has_custom_fetch);
2396 }
2397 Err(error) => {
2398 crate::server::sync_custom_fetch_proxy(&id, bridge, false);
2399 tracing::warn!(
2400 provider = %id,
2401 %error,
2402 "failed to refresh plugin auth loader after oauth callback"
2403 );
2404 }
2405 }
2406 }
2407
2408 Ok(Json(true))
2409}
2410
2411fn config_routes() -> Router<Arc<ServerState>> {
2412 Router::new()

Callers

nothing calls this directly

Calls 7

get_plugin_loaderFunction · 0.85
newFunction · 0.85
sync_custom_fetch_proxyFunction · 0.85
auth_bridgeMethod · 0.80
callbackMethod · 0.45
cloneMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected