I want to build a little app for myself (learning purposes) for the service http://quote.fm. They provide a oAuth 2.0 Api with a Request Token and a Authorize Url.
How can i use scribe with this api? I found this site in the scribe wiki but it only explains how to add an oAuth 1.0a api(?)
Any suggestions? Thank you!
Regards,
Chris
edit:
Tried to implement the api with the DefaultApi20 class but i am stuck now in the GetRequestToken call which results in an exception:
java.lang.UnsupportedOperationException: Unsupported operation, please use 'getAuthorizationUrl' and redirect your users there
OAuthHelper
private OAuthService service;
private Token requestToken;
private String AuthUrl;
public OAuthHelper() {
service = new ServiceBuilder()
.provider(QuoteFmApi.class)
.apiKey("...")
.apiSecret("...")
.callback("quotefmsharetoread://authed")
.build();
}
public void GetRequestToken() {
requestToken = service.getRequestToken();
}
public String GetAuthUrl() {
AuthUrl = service.getAuthorizationUrl(requestToken);
return AuthUrl;
}
QuoteFmApi.class:
public class QuoteFmApi extends DefaultApi20 {
private static final String AUTHORIZATION_URL =
"https://quote.fm/labs/authorize?client_id=%s&redirect_uri=%s&scope=%s&response_type=code";
@Override
public String getAuthorizationUrl(OAuthConfig config)
{
return String.format(AUTHORIZATION_URL, config.getApiKey(), config.getCallback(),
config.getScope());
}
@Override
public String getAccessTokenEndpoint()
{
return "https://quote.fm/api/oauth/token";
}
@Override
public AccessTokenExtractor getAccessTokenExtractor()
{
return new JsonTokenExtractor();
}