I'm using scribe to connect with QTIWorks
I found this question How to create a oAuth request using java?
I write this QTIWorks class
package testscribe;
import org.scribe.builder.api.DefaultApi10a;
import org.scribe.model.Token;
import org.scribe.model.Verb;
public class QTIWorks extends DefaultApi10a {
@Override
public Verb getRequestTokenVerb()
{
return Verb.GET;
}
@Override
public String getRequestTokenEndpoint() {
return "https://webapps.ph.ed.ac.uk/qtiworks-dev2/lti/domainlaunch";
}
@Override
public String getAccessTokenEndpoint() {
return "none";
}
/*@Override
public String getAuthorizationUrl(Token requestToken) {
return "none";*/
@Override
public String getAuthorizationUrl(Token token) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
and this is Main class
package testscribe;
import org.scribe.builder.ServiceBuilder;
import org.scribe.model.OAuthRequest;
import org.scribe.model.Response;
import org.scribe.model.Token;
import org.scribe.model.Verb;
import org.scribe.oauth.OAuthService;
public class Main {
public static void main(String[] args){
OAuthService service = new ServiceBuilder().provider(QTIWorks.class).apiKey("gmail.com/zeina.helwani").apiSecret("v6wPuluQXPwX3vva71ZpR7i1fsbGPaT6")
.scope("API.Public").build();
Token requestToken = service.getRequestToken();
OAuthRequest request = new OAuthRequest(Verb.POST,"https://webapps.ph.ed.ac.uk/qtiworks-dev2/lti/domainlaunch");
service.signRequest(requestToken, request);
Response response = request.send();
System.out.println(response.getBody());
}
}
but it is give me this error
Exception in thread "main" org.scribe.exceptions.OAuthException: Response body is incorrect. Can't extract token and secret from this: '
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>QTIWorks - Method Not Allowed (HTTP Error 405)</title>
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Open+Sans:400,400italic,700,700italic|Ubuntu:500">
<link rel="stylesheet" href="/qtiworks-dev2/lib/960/reset.css">
<link rel="stylesheet" href="/qtiworks-dev2/lib/960/text.css">
<link rel="stylesheet" href="/qtiworks-dev2/lib/fluid960gs/grid.css">
<link rel="stylesheet" href="/qtiworks-dev2/includes/qtiworks.css?v=1.0-SNAPSHOT">
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.min.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
<script src="/qtiworks-dev2/includes/qtiworks.js?v=1.0-SNAPSHOT"></script>
<!--[if lt IE 9]><script src="/qtiworks-dev2/lib/html5shiv.min.js"></script><![endif]-->
</head>
<body class="page">
<div class="container_12">
<header class="pageHeader">
<h1><a href="/qtiworks-dev2/">QTIWorks</a></h1>
</header>
<h2>Method Not Allowed (HTTP Error 405)</h2>
<p>You used an HTTP method which is not allowed here.</p><h3>Further Details</h3>
<strong>Message:</strong> Request method 'GET' not supported<br>
<strong>Status Code:</strong> 405<br>
<strong>Request URI:</strong> /qtiworks-dev2/lti/domainlaunch<br>
<div class="clear"></div>
<footer>
<div class="logos">
<a href="http://www.jisc.ac.uk"><img src="/qtiworks-dev2/includes/images/jisc75.png" width="75" height="50" alt="JISC Logo" /></a>
<a href="http://www.ed.ac.uk"><img src="/qtiworks-dev2/includes/images/uoe.png" width="60" height="60" alt="University of Edinburgh Logo" /></a>
</div>
<div class="copyright">
<p>
QTIWorks 1.0-SNAPSHOT ‒ <a href="/qtiworks-dev2/release-notes.jsp">Release notes</a>
</p>
<p>
Copyright © Thu Apr 09 13:16:35 BST 2015
<a href="http://www.ph.ed.ac.uk">The School of Physics and Astronomy</a>,
<a href="http://www.ed.ac.uk">The University of Edinburgh</a>.
</p>
<p>
Contact: <a href="mailto:david.mckain@ed.ac.uk">David McKain</a>
</p>
<p>
The University of Edinburgh is a charitable body, registered in Scotland,
with registration number SC005336.
</p>
</div>
</footer>
</div>
</body>
</html>
at org.scribe.extractors.TokenExtractorImpl.extract(TokenExtractorImpl.java:41)
at org.scribe.extractors.TokenExtractorImpl.extract(TokenExtractorImpl.java:27)
at org.scribe.oauth.OAuth10aServiceImpl.getRequestToken(OAuth10aServiceImpl.java:64)
at org.scribe.oauth.OAuth10aServiceImpl.getRequestToken(OAuth10aServiceImpl.java:40)
at org.scribe.oauth.OAuth10aServiceImpl.getRequestToken(OAuth10aServiceImpl.java:45)
at testscribe.Main.main(Main.java:24)
Java Result: 1
I think this url "https://webapps.ph.ed.ac.uk/qtiworks-dev2/lti/domainlaunch" is invalid, but I don't know what I should use.