Merge branch 'groups'
This commit is contained in:
commit
f61eda3990
@ -72,11 +72,31 @@ public class AuthorizationService {
|
|||||||
String[] tokens = response.split("&");
|
String[] tokens = response.split("&");
|
||||||
oauth_token = tokens[0].replace("oauth_token=", "");
|
oauth_token = tokens[0].replace("oauth_token=", "");
|
||||||
oauth_token_secret = tokens[1].replace("oauth_token_secret=", "");
|
oauth_token_secret = tokens[1].replace("oauth_token_secret=", "");
|
||||||
return createUserAccountAndReturnHeaderToken(oauth_token, oauth_token_secret);
|
TokenResponseDTO tokenResponseDTO = createUserAccountAndReturnHeaderToken(oauth_token, oauth_token_secret);
|
||||||
|
updateUserGroupsAndStudents(oauth_token, oauth_token_secret);
|
||||||
|
//logOut(oauth_token, oauth_token_secret);
|
||||||
|
return tokenResponseDTO;
|
||||||
}
|
}
|
||||||
return new TokenResponseDTO("authorization failed", null);
|
return new TokenResponseDTO("authorization failed", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateUserGroupsAndStudents(String oauth_token, String oauth_token_secret) throws UnsupportedEncodingException, InvalidKeyException, NoSuchAlgorithmException {
|
||||||
|
List<NameValuePair> queryParams = new ArrayList<>();
|
||||||
|
queryParams.add(new BasicNameValuePair("fields", "course%5Funit%5Fid"));
|
||||||
|
queryParams.add(new BasicNameValuePair("oauth_consumer_key", propertiesLoader.getKey()));
|
||||||
|
queryParams.add(new BasicNameValuePair("oauth_nonce", "" + (int) (Math.random() * 100000000)));
|
||||||
|
queryParams.add(new BasicNameValuePair("oauth_signature_method", "HMAC-SHA1"));
|
||||||
|
queryParams.add(new BasicNameValuePair("oauth_timestamp", "" + (System.currentTimeMillis() / 1000)));
|
||||||
|
queryParams.add(new BasicNameValuePair("oauth_token", oauth_token));
|
||||||
|
queryParams.add(new BasicNameValuePair("oauth_version", "1.0"));
|
||||||
|
String oauth_signature = getSignature("GET", URLEncoder.encode(propertiesLoader.getUsosApiURL() + "/groups/user", ENC), URLEncoder.encode(URLEncodedUtils.format(queryParams, ENC), ENC), oauth_token_secret);
|
||||||
|
queryParams.add(new BasicNameValuePair("oauth_signature", oauth_signature));
|
||||||
|
String url = "/groups/user?" + URLEncodedUtils.format(queryParams, ENC);
|
||||||
|
|
||||||
|
String courses = when().get(url).body().asString();
|
||||||
|
System.out.println(courses);
|
||||||
|
}
|
||||||
|
|
||||||
public String requestToken(String oauth_callback) throws UnsupportedEncodingException, InvalidKeyException, NoSuchAlgorithmException {
|
public String requestToken(String oauth_callback) throws UnsupportedEncodingException, InvalidKeyException, NoSuchAlgorithmException {
|
||||||
List<NameValuePair> queryParams = new ArrayList<>();
|
List<NameValuePair> queryParams = new ArrayList<>();
|
||||||
queryParams.add(new BasicNameValuePair("oauth_callback", oauth_callback));
|
queryParams.add(new BasicNameValuePair("oauth_callback", oauth_callback));
|
||||||
|
Loading…
Reference in New Issue
Block a user