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

Function oauth_authorize

crates/opencode-server/src/routes.rs:2352–2371  ·  view source on GitHub ↗
(
    State(_state): State<Arc<ServerState>>,
    Path(id): Path<String>,
    Json(req): Json<OAuthAuthorizeRequest>,
)

Source from the content-addressed store, hash-verified

2350}
2351
2352async fn oauth_authorize(
2353 State(_state): State<Arc<ServerState>>,
2354 Path(id): Path<String>,
2355 Json(req): Json<OAuthAuthorizeRequest>,
2356) -> Result<Json<OAuthAuthorizeResponse>> {
2357 let loader = get_plugin_loader()
2358 .ok_or_else(|| ApiError::NotFound("no plugin loader initialized".to_string()))?;
2359 let authorization = ProviderAuth::authorize(loader, &id, req.method, None)
2360 .await
2361 .map_err(|e| ApiError::BadRequest(e.to_string()))?;
2362
2363 Ok(Json(OAuthAuthorizeResponse {
2364 url: authorization.url,
2365 method_type: match authorization.method {
2366 AuthMethodType::Auto => "auto".to_string(),
2367 AuthMethodType::Code => "code".to_string(),
2368 },
2369 instructions: authorization.instructions,
2370 }))
2371}
2372
2373#[derive(Debug, Deserialize)]
2374pub struct OAuthCallbackRequest {

Callers

nothing calls this directly

Calls 2

get_plugin_loaderFunction · 0.85
authorizeFunction · 0.50

Tested by

no test coverage detected