I try to conect to discogs via oauth 1.0a. I am using an example from this page: http://devjay.org/?p=22#comment-979
My DiscoGSApi10a.java looks exact the same. I got a property file and my main class which I reduced in case of searching for the error:
public class Auth2 {
public static void main(String[] args) throws FileNotFoundException, IOException {
Properties configProps = new Properties();
configProps.load(new FileInputStream("src/main/resources/config.properties"));
String consumer_key = configProps.getProperty("consumer.key");
String consumer_secret = configProps.getProperty("consumer.secret");
String user_agent_string = configProps.getProperty("useragent.string");
// will be empty on the first run, as token is not yet provided
String config_token = configProps.getProperty("accesstoken.key", "");
String config_secret = configProps.getProperty("accesstoken.secret", "");
//this requires user interaction if no access token is found in config.properties
OAuthService service = new ServiceBuilder()
.provider(DiscoGSApi10a.class)
.apiKey(consumer_key)
.apiSecret(consumer_secret)
.debug()
.build();
Token requestToken = service.getRequestToken();
System.out.println("Token RAW: "+ requestToken.getRawResponse());
}
}
The log and error is as follows:
obtaining request token from https://api.discogs.com/oauth/request_token setting oauth_callback to oob generating signature... using base64 encoder: DatatypeConverter base string is: POST&https%3A%2F%2Fapi.discogs.com%2Foauth%2Frequest_token&oauth_callback%3Doob%26oauth_consumer_key%YOUR_CONSUMER_KEY%26oauth_nonce%3D1825647227%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1420357886%26oauth_version%3D1.0 signature is: WbSZr46nikDsZGzo9gSeJcP28Xk= appended additional OAuth parameters: { oauth_callback -> oob , oauth_signature -> WbSZr46nikDsZGzo9gSeJcP28Xk= , oauth_version -> 1.0 , oauth_nonce -> 1825647227 , oauth_signature_method -> HMAC-SHA1 , oauth_consumer_key -> IgUpkXTCBbIZNQrlXiYk , oauth_timestamp -> 1420357886 } using Http Header signature sending request... Exception in thread "main" org.scribe.exceptions.OAuthConnectionException: There was a problem while creating a connection to the remote service. at org.scribe.model.Request.send(Request.java:70) at org.scribe.oauth.OAuth10aServiceImpl.getRequestToken(OAuth10aServiceImpl.java:59) at org.scribe.oauth.OAuth10aServiceImpl.getRequestToken(OAuth10aServiceImpl.java:40) at org.scribe.oauth.OAuth10aServiceImpl.getRequestToken(OAuth10aServiceImpl.java:45) at de.ms.discogs.auth.Auth2.main(Auth2.java:43) Caused by: java.net.SocketException: Unexpected end of file from server at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:772) at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:633) at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:769) at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:633) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1323) at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338) at org.scribe.model.Response.(Response.java:30) at org.scribe.model.Request.doSend(Request.java:117) at org.scribe.model.Request.send(Request.java:66) ... 4 more
Why cant I even connect to the remote service ?
Regards LStrike