Skip to content

Commit

Permalink
Merge pull request #75 from RADAR-base/fixes
Browse files Browse the repository at this point in the history
Add fixes according to changes to rest source authorizer
  • Loading branch information
mpgxvii authored Mar 2, 2021
2 parents 809caac + 541a304 commit 7e44c39
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ If the ManagementPortal is used to authenticate against the user repository, ple
```
Client ID: fitbit.user.repository.client.id
Client Secret: fitbit.user.repository.client.secret
Scope: SUBJECT.READ
Scope: SUBJECT.READ MEASUREMENT.CREATE
Resources: res_restAuthorizer
Grant types: client_credentials
Access Token validity: 600
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,19 @@ public class LocalUser implements User {
private static final Pattern ILLEGAL_CHARACTERS_PATTERN = Pattern.compile("[^a-zA-Z0-9_-]");
private String id;
private String version;
private String externalUserId;
private String projectId;
private String userId;
private String sourceId;
private Instant startDate = Instant.parse("2017-01-01T00:00:00Z");
private Instant endDate = Instant.parse("9999-12-31T23:59:59.999Z");

@JsonProperty("serviceUserId")
private String serviceUserId;

@JsonProperty("oauth2")
private OAuth2UserCredentials oauth2Credentials = new OAuth2UserCredentials();

@JsonProperty("authorized")
@JsonProperty("isAuthorized")
private Boolean isAuthorized;

@JsonIgnore
Expand All @@ -62,7 +64,7 @@ public void setId(String id) {
}

public String getExternalUserId() {
return externalUserId;
return serviceUserId;
}

public String getProjectId() {
Expand Down Expand Up @@ -95,7 +97,7 @@ public void setOauth2Credentials(OAuth2UserCredentials oauth2Credentials) {

@JsonSetter("fitbitUserId")
public void setFitbitUserId(String id) {
this.externalUserId = id;
this.serviceUserId = id;
}

@Override
Expand All @@ -120,7 +122,7 @@ public LocalUser copy() {
LocalUser copy = new LocalUser();
copy.id = id;
copy.version = version;
copy.externalUserId = externalUserId;
copy.serviceUserId = serviceUserId;
copy.projectId = projectId;
copy.userId = userId;
copy.startDate = startDate;
Expand All @@ -142,7 +144,7 @@ public synchronized SchemaAndValue getObservationKey(AvroData avroData) {
public String toString() {
return "LocalUser{id='" + id + '\''
+ ", version='" + version + '\''
+ ", externalUserId='" + externalUserId + '\''
+ ", externalUserId='" + serviceUserId + '\''
+ ", projectId='" + projectId + '\''
+ ", userId='" + userId + '\''
+ ", sourceId='" + sourceId + '\''
Expand All @@ -161,7 +163,7 @@ public boolean equals(Object o) {
LocalUser localUser = (LocalUser) o;
return Objects.equals(id, localUser.id)
&& Objects.equals(version, localUser.version)
&& Objects.equals(externalUserId, localUser.externalUserId)
&& Objects.equals(serviceUserId, localUser.serviceUserId)
&& Objects.equals(projectId, localUser.projectId)
&& Objects.equals(userId, localUser.userId)
&& Objects.equals(sourceId, localUser.sourceId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void initialize(RestSourceConnectorConfig config) {
this.repositoryClient = new OAuth2Client.Builder()
.credentials(clientId, clientSecret)
.endpoint(tokenUrl)
.scopes("SUBJECT.READ")
.scopes("SUBJECT.READ MEASUREMENT.CREATE")
.httpClient(client)
.build();
} else if (clientId != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@
package org.radarbase.connect.rest.fitbit.user;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.ArrayList;
import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
public class Users {
private final List<LocalUser> users;


@JsonCreator
public Users(@JsonProperty("users") List<LocalUser> users) {
this.users = new ArrayList<>(users);
Expand Down

0 comments on commit 7e44c39

Please sign in to comment.