|
22 | 22 |
|
23 | 23 | import com.fasterxml.jackson.core.JsonProcessingException; |
24 | 24 | import com.fasterxml.jackson.databind.ObjectReader; |
| 25 | +import io.confluent.common.config.ConfigException; |
25 | 26 | import java.io.IOException; |
26 | 27 | import java.net.MalformedURLException; |
27 | 28 | import java.net.URL; |
@@ -91,30 +92,22 @@ public void initialize(RestSourceConnectorConfig config) { |
91 | 92 | this.baseUrl = fitbitConfig.getFitbitUserRepositoryUrl(); |
92 | 93 | this.containedUsers.addAll(fitbitConfig.getFitbitUsers()); |
93 | 94 |
|
94 | | - try { |
95 | | - URL tokenUrl = fitbitConfig.getFitbitUserRepositoryTokenUrl(); |
96 | | - String clientId = fitbitConfig.getFitbitUserRepositoryClientId(); |
97 | | - String clientSecret = fitbitConfig.getFitbitUserRepositoryClientSecret(); |
| 95 | + URL tokenUrl = fitbitConfig.getFitbitUserRepositoryTokenUrl(); |
| 96 | + String clientId = fitbitConfig.getFitbitUserRepositoryClientId(); |
| 97 | + String clientSecret = fitbitConfig.getFitbitUserRepositoryClientSecret(); |
98 | 98 |
|
99 | | - if (tokenUrl != null) { |
100 | | - if (clientId.isEmpty()) { |
101 | | - throw new ConnectException("Client ID for user repository is not set."); |
102 | | - } |
103 | | - this.repositoryClient = new OAuth2Client.Builder() |
104 | | - .credentials( |
105 | | - fitbitConfig |
106 | | - .getString(FitbitRestSourceConnectorConfig.FITBIT_USER_REPOSITORY_CLIENT_ID_CONFIG), |
107 | | - fitbitConfig.getString( |
108 | | - FitbitRestSourceConnectorConfig.FITBIT_USER_REPOSITORY_CLIENT_SECRET_CONFIG)) |
109 | | - .endpoint(tokenUrl) |
110 | | - .scopes("SUBJECT.READ") |
111 | | - .httpClient(client) |
112 | | - .build(); |
113 | | - } else if (clientId != null) { |
114 | | - basicCredentials = Credentials.basic(clientId, clientSecret); |
| 99 | + if (tokenUrl != null) { |
| 100 | + if (clientId.isEmpty()) { |
| 101 | + throw new ConfigException("Client ID for user repository is not set."); |
115 | 102 | } |
116 | | - } catch (MalformedURLException ex) { |
117 | | - throw new ConnectException("OAuth 2.0 server URL is malformed", ex); |
| 103 | + this.repositoryClient = new OAuth2Client.Builder() |
| 104 | + .credentials(clientId, clientSecret) |
| 105 | + .endpoint(tokenUrl) |
| 106 | + .scopes("SUBJECT.READ") |
| 107 | + .httpClient(client) |
| 108 | + .build(); |
| 109 | + } else if (clientId != null) { |
| 110 | + basicCredentials = Credentials.basic(clientId, clientSecret); |
118 | 111 | } |
119 | 112 | } |
120 | 113 |
|
|
0 commit comments