|
16 | 16 |
|
17 | 17 | package com.bytechef.platform.connection.facade; |
18 | 18 |
|
| 19 | +import static com.bytechef.component.definition.Authorization.CLIENT_ID; |
| 20 | +import static com.bytechef.component.definition.Authorization.CLIENT_SECRET; |
| 21 | + |
19 | 22 | import com.bytechef.commons.util.CollectionUtils; |
20 | 23 | import com.bytechef.component.definition.Authorization; |
21 | 24 | import com.bytechef.component.definition.Authorization.AuthorizationCallbackResponse; |
@@ -94,16 +97,29 @@ public long create(ConnectionDTO connectionDTO, PlatformType type) { |
94 | 97 | if (authorizationType == AuthorizationType.OAUTH2_AUTHORIZATION_CODE || |
95 | 98 | authorizationType == AuthorizationType.OAUTH2_AUTHORIZATION_CODE_PKCE) { |
96 | 99 |
|
| 100 | + Map<String, ?> predefinedParameters = oAuth2Service.checkPredefinedParameters( |
| 101 | + connection.getComponentName(), connection.getParameters()); |
| 102 | + |
97 | 103 | AuthorizationCallbackResponse authorizationCallbackResponse = |
98 | 104 | connectionDefinitionService.executeAuthorizationCallback( |
99 | 105 | connection.getComponentName(), connection.getConnectionVersion(), |
100 | | - connection.getAuthorizationType(), |
101 | | - oAuth2Service.checkPredefinedParameters( |
102 | | - connection.getComponentName(), connection.getParameters()), |
| 106 | + connection.getAuthorizationType(), predefinedParameters, |
103 | 107 | oAuth2Service.getRedirectUri()); |
104 | 108 |
|
105 | 109 | connection.putAllParameters(authorizationCallbackResponse.result()); |
106 | 110 |
|
| 111 | + Map<String, ?> parameters = connection.getParameters(); |
| 112 | + |
| 113 | + Object clientId = parameters.get(CLIENT_ID); |
| 114 | + Object clientSecret = parameters.get(CLIENT_SECRET); |
| 115 | + |
| 116 | + if ((clientId == null || clientId.equals("")) && (clientSecret == null || clientSecret.equals(""))) { |
| 117 | + connection.putAllParameters( |
| 118 | + Map.of( |
| 119 | + CLIENT_ID, predefinedParameters.get(CLIENT_ID), |
| 120 | + CLIENT_SECRET, predefinedParameters.get(CLIENT_SECRET))); |
| 121 | + } |
| 122 | + |
107 | 123 | if (logger.isWarnEnabled() && !connection.containsParameter(Authorization.REFRESH_TOKEN)) { |
108 | 124 | logger.warn( |
109 | 125 | "OAuth2 authorization code connection for component {} does not contain refresh token", |
|
0 commit comments