(
loader: &PluginLoader,
provider_id: &str,
method: usize,
inputs: Option<HashMap<String, String>>,
)
| 40 | } |
| 41 | |
| 42 | pub async fn authorize( |
| 43 | loader: &PluginLoader, |
| 44 | provider_id: &str, |
| 45 | method: usize, |
| 46 | inputs: Option<HashMap<String, String>>, |
| 47 | ) -> Result<Authorization, AuthError> { |
| 48 | let bridge = loader |
| 49 | .auth_bridge(provider_id) |
| 50 | .await |
| 51 | .ok_or_else(|| AuthError::OauthMissing(provider_id.to_string()))?; |
| 52 | let result = bridge |
| 53 | .authorize(method, inputs) |
| 54 | .await |
| 55 | .map_err(|_| AuthError::OauthCallbackFailed)?; |
| 56 | |
| 57 | let method_type = match result.method.as_deref() { |
| 58 | Some("code") => AuthMethodType::Code, |
| 59 | _ => AuthMethodType::Auto, |
| 60 | }; |
| 61 | |
| 62 | Ok(Authorization { |
| 63 | url: result.url.unwrap_or_default(), |
| 64 | method: method_type, |
| 65 | instructions: result.instructions.unwrap_or_default(), |
| 66 | }) |
| 67 | } |
| 68 | |
| 69 | pub async fn callback( |
| 70 | &self, |
no test coverage detected