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

Method authorize

crates/opencode-plugin/src/subprocess/auth.rs:87–110  ·  view source on GitHub ↗

Start an OAuth authorization flow for the given method index. Returns the authorization URL and instructions for the user.

(
        &self,
        method_index: usize,
        inputs: Option<HashMap<String, String>>,
    )

Source from the content-addressed store, hash-verified

85 ///
86 /// Returns the authorization URL and instructions for the user.
87 pub async fn authorize(
88 &self,
89 method_index: usize,
90 inputs: Option<HashMap<String, String>>,
91 ) -> Result<PluginAuthorizeResult, PluginAuthError> {
92 if method_index >= self.meta.methods.len() {
93 return Err(PluginAuthError::InvalidMethodIndex {
94 plugin: self.client.name().to_string(),
95 index: method_index,
96 });
97 }
98
99 let inputs_value = inputs.map(|m| serde_json::to_value(m).unwrap_or(Value::Null));
100 let result = self
101 .client
102 .auth_authorize(method_index, inputs_value)
103 .await?;
104
105 Ok(PluginAuthorizeResult {
106 url: result.url,
107 instructions: result.instructions,
108 method: result.method,
109 })
110 }
111
112 /// Complete the OAuth callback with an optional authorization code.
113 pub async fn callback(&self, code: Option<&str>) -> Result<Value, PluginAuthError> {

Callers 1

handleAuthAuthorizeFunction · 0.45

Calls 2

auth_authorizeMethod · 0.80
nameMethod · 0.45

Tested by

no test coverage detected