Skip to content

Commit 7e44c39

Browse files
authored
Merge pull request #75 from RADAR-base/fixes
Add fixes according to changes to rest source authorizer
2 parents 809caac + 541a304 commit 7e44c39

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ If the ManagementPortal is used to authenticate against the user repository, ple
9393
```
9494
Client ID: fitbit.user.repository.client.id
9595
Client Secret: fitbit.user.repository.client.secret
96-
Scope: SUBJECT.READ
96+
Scope: SUBJECT.READ MEASUREMENT.CREATE
9797
Resources: res_restAuthorizer
9898
Grant types: client_credentials
9999
Access Token validity: 600

kafka-connect-fitbit-source/src/main/java/org/radarbase/connect/rest/fitbit/user/LocalUser.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,19 @@ public class LocalUser implements User {
3535
private static final Pattern ILLEGAL_CHARACTERS_PATTERN = Pattern.compile("[^a-zA-Z0-9_-]");
3636
private String id;
3737
private String version;
38-
private String externalUserId;
3938
private String projectId;
4039
private String userId;
4140
private String sourceId;
4241
private Instant startDate = Instant.parse("2017-01-01T00:00:00Z");
4342
private Instant endDate = Instant.parse("9999-12-31T23:59:59.999Z");
4443

44+
@JsonProperty("serviceUserId")
45+
private String serviceUserId;
46+
4547
@JsonProperty("oauth2")
4648
private OAuth2UserCredentials oauth2Credentials = new OAuth2UserCredentials();
4749

48-
@JsonProperty("authorized")
50+
@JsonProperty("isAuthorized")
4951
private Boolean isAuthorized;
5052

5153
@JsonIgnore
@@ -62,7 +64,7 @@ public void setId(String id) {
6264
}
6365

6466
public String getExternalUserId() {
65-
return externalUserId;
67+
return serviceUserId;
6668
}
6769

6870
public String getProjectId() {
@@ -95,7 +97,7 @@ public void setOauth2Credentials(OAuth2UserCredentials oauth2Credentials) {
9597

9698
@JsonSetter("fitbitUserId")
9799
public void setFitbitUserId(String id) {
98-
this.externalUserId = id;
100+
this.serviceUserId = id;
99101
}
100102

101103
@Override
@@ -120,7 +122,7 @@ public LocalUser copy() {
120122
LocalUser copy = new LocalUser();
121123
copy.id = id;
122124
copy.version = version;
123-
copy.externalUserId = externalUserId;
125+
copy.serviceUserId = serviceUserId;
124126
copy.projectId = projectId;
125127
copy.userId = userId;
126128
copy.startDate = startDate;
@@ -142,7 +144,7 @@ public synchronized SchemaAndValue getObservationKey(AvroData avroData) {
142144
public String toString() {
143145
return "LocalUser{id='" + id + '\''
144146
+ ", version='" + version + '\''
145-
+ ", externalUserId='" + externalUserId + '\''
147+
+ ", externalUserId='" + serviceUserId + '\''
146148
+ ", projectId='" + projectId + '\''
147149
+ ", userId='" + userId + '\''
148150
+ ", sourceId='" + sourceId + '\''
@@ -161,7 +163,7 @@ public boolean equals(Object o) {
161163
LocalUser localUser = (LocalUser) o;
162164
return Objects.equals(id, localUser.id)
163165
&& Objects.equals(version, localUser.version)
164-
&& Objects.equals(externalUserId, localUser.externalUserId)
166+
&& Objects.equals(serviceUserId, localUser.serviceUserId)
165167
&& Objects.equals(projectId, localUser.projectId)
166168
&& Objects.equals(userId, localUser.userId)
167169
&& Objects.equals(sourceId, localUser.sourceId)

kafka-connect-fitbit-source/src/main/java/org/radarbase/connect/rest/fitbit/user/ServiceUserRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public void initialize(RestSourceConnectorConfig config) {
101101
this.repositoryClient = new OAuth2Client.Builder()
102102
.credentials(clientId, clientSecret)
103103
.endpoint(tokenUrl)
104-
.scopes("SUBJECT.READ")
104+
.scopes("SUBJECT.READ MEASUREMENT.CREATE")
105105
.httpClient(client)
106106
.build();
107107
} else if (clientId != null) {

kafka-connect-fitbit-source/src/main/java/org/radarbase/connect/rest/fitbit/user/Users.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@
1818
package org.radarbase.connect.rest.fitbit.user;
1919

2020
import com.fasterxml.jackson.annotation.JsonCreator;
21+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
2122
import com.fasterxml.jackson.annotation.JsonProperty;
23+
2224
import java.util.ArrayList;
2325
import java.util.List;
2426

27+
@JsonIgnoreProperties(ignoreUnknown = true)
2528
public class Users {
2629
private final List<LocalUser> users;
2730

28-
2931
@JsonCreator
3032
public Users(@JsonProperty("users") List<LocalUser> users) {
3133
this.users = new ArrayList<>(users);

0 commit comments

Comments
 (0)