Checkpoint
This commit is contained in:
54
buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java
Executable file
54
buisnesslogic/src/main/java/com/plannaplan/services/UsosApiService.java
Executable file
@ -0,0 +1,54 @@
|
||||
package com.plannaplan.services;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.social.oauth1.OAuth1Parameters;
|
||||
import org.springframework.social.support.ClientHttpRequestFactorySelector;
|
||||
// import org.springframework.social.oauth1.OAuth1Template;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.social.oauth1.*;
|
||||
import org.springframework.http.client.ClientHttpRequestInterceptor;
|
||||
// import org.springframework.social.oauth1.ProtectedResourceClientFactory;
|
||||
|
||||
@Service
|
||||
public class UsosApiService {
|
||||
public UsosApiService() {
|
||||
|
||||
}
|
||||
|
||||
public void xd() {
|
||||
RestTemplate xddd = new RestTemplate();
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("oauth_version", "1.0");
|
||||
headers.set("oauth_signature_method", "HMAC-SHA1");
|
||||
headers.set("oauth_consumer_key", "e6jbeN57HC99MfsfmZwN");
|
||||
headers.set("oauth_signature", "fhcLdwerJyzZBGA9WnAYzbySJRW9Wv5wj3h8uVgp");
|
||||
headers.set("oauth_nonce", "" + (int) (Math.random() * 100000000));
|
||||
headers.set("oauth_timestamp", "" + (System.currentTimeMillis() / 1000));
|
||||
|
||||
// BasicAuthenticationInterceptor
|
||||
|
||||
// OAuth1Credentials credentials;
|
||||
// RestTemplate client = new
|
||||
// RestTemplate(ClientHttpRequestFactorySelector.getRequestFactory());
|
||||
// OAuth1RequestInterceptor interceptor = new
|
||||
// OAuth1RequestInterceptor(credentials);
|
||||
// List<ClientHttpRequestInterceptor> interceptors = new
|
||||
// LinkedList<ClientHttpRequestInterceptor>();
|
||||
// interceptors.add(interceptor);
|
||||
// client.setInterceptors(interceptors);
|
||||
|
||||
HttpEntity<String> entity = new HttpEntity<>(headers);
|
||||
|
||||
ResponseEntity<String> result = xddd.exchange("https://usosapidemo.amu.edu.pl/services/users/user",
|
||||
HttpMethod.GET, entity, String.class);
|
||||
System.out.println(result);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user