diff --git a/backend/oauth_connect.json b/backend/oauth_connect.json index 2b1edfdf6f..72962c19ee 100644 --- a/backend/oauth_connect.json +++ b/backend/oauth_connect.json @@ -76,8 +76,6 @@ "auth_url": "https://www.linkedin.com/oauth/v2/authorization", "token_url": "https://www.linkedin.com/oauth/v2/accessToken", "scopes": ["w_member_social"], - "extra_params_callback": { - "redirect_uri": "https://app.windmill.dev/oauth/callback/linkedin" - } + "req_body_auth": true } } diff --git a/backend/windmill-api/src/oauth2.rs b/backend/windmill-api/src/oauth2.rs index 3eda008b59..988acbc12e 100644 --- a/backend/windmill-api/src/oauth2.rs +++ b/backend/windmill-api/src/oauth2.rs @@ -91,6 +91,7 @@ pub struct OAuthConfig { scopes: Option>, extra_params: Option>, extra_params_callback: Option>, + req_body_auth: Option, } #[derive(Clone, Debug, Serialize, Deserialize)] @@ -209,6 +210,7 @@ pub async fn build_oauth_clients(base_url: &str) -> anyhow::Result { scopes: None, extra_params: None, extra_params_callback: None, + req_body_auth: None, }, v.clone(), false, @@ -241,6 +243,9 @@ pub fn build_basic_client( }; let mut client = OClient::new(client_params.id, auth_url, token_url); + if config.req_body_auth.unwrap_or(false) { + client.set_auth_type(AuthType::RequestBody); + } client.set_client_secret(client_params.secret.clone()); client.set_redirect_url(Url::parse(&redirect_url).expect("Invalid redirect URL")); // Set up the config for the Github OAuth2 process. @@ -309,7 +314,7 @@ async fn connect( struct CreateAccount { client: String, owner: String, - refresh_token: String, + refresh_token: Option, expires_in: i64, } async fn create_account( @@ -987,6 +992,7 @@ async fn exchange_code( token_url = token_url.param(key, value) } } + token_url .with_client(http_client) .execute::() diff --git a/frontend/src/lib/components/AppConnect.svelte b/frontend/src/lib/components/AppConnect.svelte index 403fe8c4a7..adc1c39454 100644 --- a/frontend/src/lib/components/AppConnect.svelte +++ b/frontend/src/lib/components/AppConnect.svelte @@ -170,13 +170,13 @@ } let account: number | undefined = undefined - if (valueToken?.refresh_token != undefined && valueToken?.expires_in != undefined) { + if (valueToken?.refresh_token != undefined || valueToken?.expires_in != undefined) { account = Number( await OauthService.createAccount({ workspace: $workspaceStore!, requestBody: { - refresh_token: valueToken.refresh_token!, - expires_in: valueToken.expires_in!, + refresh_token: valueToken.refresh_token, + expires_in: valueToken.expires_in, owner: path.split('/').slice(0, 2).join('/'), client: resource_type }