Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d0fa8689cb | ||
|
|
896e738156 | ||
|
|
cf84381127 | ||
|
|
806d548629 | ||
|
|
959c093620 | ||
|
|
fc2c46bd3a | ||
|
|
f1ecabdb52 |
No files matched your search
@@ -13,3 +13,8 @@
|
||||
* FIX: Fixed Evernote Api (uses GET for request and access tokens)
|
||||
* REFACTOR: URLEncoding stuff. LinkedIn specific decoder is no longer needed
|
||||
* FEATURE: Added Google example
|
||||
|
||||
[1.0.9]
|
||||
|
||||
* FEATURE: Token made Serializable
|
||||
* FIX: Google Api encoding issues (thanks @roger and @klakegg)
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>org.scribe</groupId>
|
||||
<artifactId>scribe</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.0.8</version>
|
||||
<version>1.0.9</version>
|
||||
<name>Scribe OAuth Library</name>
|
||||
<description>The best OAuth library out there</description>
|
||||
<url>http://github.com/fernandezpablo85/scribe-java</url>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.scribe.builder.api;
|
||||
|
||||
import org.scribe.model.*;
|
||||
|
||||
public class GoogleApi extends DefaultApi10a
|
||||
{
|
||||
@Override
|
||||
@@ -13,4 +15,16 @@ public class GoogleApi extends DefaultApi10a
|
||||
{
|
||||
return "https://www.google.com/accounts/OAuthGetRequestToken";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Verb getAccessTokenVerb()
|
||||
{
|
||||
return Verb.GET;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Verb getRequestTokenVerb()
|
||||
{
|
||||
return Verb.GET;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,16 @@
|
||||
package org.scribe.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Represents an OAuth token (either request or access token) and its secret
|
||||
*
|
||||
* @author Pablo Fernandez
|
||||
*/
|
||||
public class Token
|
||||
public class Token implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 715000866082812683L;
|
||||
|
||||
private final String token;
|
||||
private final String secret;
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.scribe.model;
|
||||
|
||||
import org.scribe.utils.*;
|
||||
|
||||
/**
|
||||
* Represents an OAuth verifier code.
|
||||
*
|
||||
@@ -7,6 +9,7 @@ package org.scribe.model;
|
||||
*/
|
||||
public class Verifier
|
||||
{
|
||||
|
||||
private final String value;
|
||||
|
||||
/**
|
||||
@@ -16,7 +19,7 @@ public class Verifier
|
||||
*/
|
||||
public Verifier(String value)
|
||||
{
|
||||
this.value = value;
|
||||
this.value = URLUtils.percentDecode(value);
|
||||
}
|
||||
|
||||
public String getValue()
|
||||
|
||||
@@ -53,6 +53,8 @@ public class OAuth10aServiceImpl implements OAuthService
|
||||
public Token getRequestToken()
|
||||
{
|
||||
OAuthRequest request = new OAuthRequest(config.getRequestTokenVerb(), config.getRequestTokenEndpoint());
|
||||
request.addOAuthParameter(OAuthConstants.CALLBACK, config.getCallback());
|
||||
if(scope != NO_SCOPE) request.addOAuthParameter(OAuthConstants.SCOPE, scope);
|
||||
addOAuthParams(request, OAuthConstants.EMPTY_TOKEN);
|
||||
addOAuthHeader(request);
|
||||
Response response = request.send();
|
||||
@@ -66,8 +68,6 @@ public class OAuth10aServiceImpl implements OAuthService
|
||||
request.addOAuthParameter(OAuthConstants.CONSUMER_KEY, config.getApiKey());
|
||||
request.addOAuthParameter(OAuthConstants.SIGN_METHOD, signatureService.getSignatureMethod());
|
||||
request.addOAuthParameter(OAuthConstants.VERSION, getVersion());
|
||||
request.addOAuthParameter(OAuthConstants.CALLBACK, config.getCallback());
|
||||
if(scope != NO_SCOPE) request.addOAuthParameter(OAuthConstants.SCOPE, scope);
|
||||
request.addOAuthParameter(OAuthConstants.SIGNATURE, getSignature(request, token));
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public class HMACSha1SignatureService implements SignatureService
|
||||
{
|
||||
Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string");
|
||||
Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty string");
|
||||
return doSign(baseString, apiSecret + '&' + tokenSecret);
|
||||
return doSign(baseString, URLUtils.percentEncode(apiSecret) + '&' + URLUtils.percentEncode(tokenSecret));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.scribe.model;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.*;
|
||||
|
||||
public class VerifierTest
|
||||
{
|
||||
@Test
|
||||
public void shouldParse()
|
||||
{
|
||||
Verifier verifier = new Verifier("p8k%2BGIjIL9PblXq%2BpH6LmT9l");
|
||||
assertEquals(verifier.getValue(), "p8k+GIjIL9PblXq+pH6LmT9l");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void shouldThrowErrorForNullString()
|
||||
{
|
||||
new Verifier(null);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package org.scribe.services;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.*;
|
||||
import org.scribe.exceptions.OAuthException;
|
||||
import org.scribe.exceptions.*;
|
||||
|
||||
public class HMACSha1SignatureServiceTest
|
||||
{
|
||||
@@ -29,7 +29,7 @@ public class HMACSha1SignatureServiceTest
|
||||
String apiSecret = "api secret";
|
||||
String tokenSecret = "token secret";
|
||||
String baseString = "base string";
|
||||
String signature = "cyxvUDZY/5cQBcBiKulaNgnhN/w=";
|
||||
String signature = "uGymw2KHOTWI699YEaoi5xyLT50=";
|
||||
assertEquals(signature, service.getSignature(baseString, apiSecret, tokenSecret));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user