Permalink
Browse files

merge from upstream

  • Loading branch information...
2 parents 794663b + 611c646 commit 228b7ace8422d5e1965a18eea5a6ea9925625826 @tbruyelle tbruyelle committed Sep 26, 2011
Showing with 859 additions and 95 deletions.
  1. +5 −0 .gitignore
  2. +3 −1 README.textile
  3. +17 −3 changelog.txt
  4. +5 −5 pom.xml
  5. +40 −0 src/main/java/org/scribe/builder/api/KaixinApi.java
  6. +43 −0 src/main/java/org/scribe/builder/api/LiveApi.java
  7. +47 −0 src/main/java/org/scribe/builder/api/NeteaseWeibooApi.java
  8. +39 −0 src/main/java/org/scribe/builder/api/PlurkApi.java
  9. +28 −0 src/main/java/org/scribe/builder/api/QWeiboApi.java
  10. +40 −0 src/main/java/org/scribe/builder/api/SapoApi.java
  11. +29 −0 src/main/java/org/scribe/builder/api/SimpleGeoApi.java
  12. +28 −0 src/main/java/org/scribe/builder/api/SinaWeiboApi.java
  13. +28 −0 src/main/java/org/scribe/builder/api/SohuWeiboApi.java
  14. +23 −0 src/main/java/org/scribe/builder/api/TwitterApi.java
  15. +1 −1 src/main/java/org/scribe/extractors/BaseStringExtractorImpl.java
  16. +1 −1 src/main/java/org/scribe/extractors/JsonTokenExtractor.java
  17. +2 −2 src/main/java/org/scribe/extractors/TokenExtractor20Impl.java
  18. +109 −33 src/main/java/org/scribe/model/Request.java
  19. +7 −7 src/main/java/org/scribe/model/Response.java
  20. +43 −0 src/main/java/org/scribe/utils/MapUtils.java
  21. +0 −41 src/main/java/org/scribe/utils/URLUtils.java
  22. +64 −0 src/test/java/org/scribe/examples/LiveExample.java
  23. +68 −0 src/test/java/org/scribe/examples/NeteaseWeiboExample.java
  24. +68 −0 src/test/java/org/scribe/examples/SinaWeiboExample.java
  25. +68 −0 src/test/java/org/scribe/examples/SohuWeiboExample.java
  26. +9 −0 src/test/java/org/scribe/extractors/TokenExtractor20Test.java
  27. +6 −0 src/test/java/org/scribe/model/ConnectionStub.java
  28. +38 −1 src/test/java/org/scribe/model/RequestTest.java
View
@@ -6,6 +6,11 @@
.settings
*.iml
+# IntelliJ Idea settings
+
+.idea
+scribe.iml
+
# Binaries
target
View
@@ -38,6 +38,8 @@ h3. Supports all major 1.0a and 2.0 OAuth APIs out-of-the-box
* Yammer
+* Windows Live
+
* and many more! check the "examples folder":http://github.com/fernandezpablo85/scribe-java/tree/master/src/test/java/org/scribe/examples
h3. Small and modular
@@ -61,7 +63,7 @@ You can pull scribe from a maven repository, just add this to your __pom.xml__ f
@<dependency>@
@<groupId>org.scribe</groupId>@
@<artifactId>scribe</artifactId>@
- @<version>1.1.3</version>@
+ @<version>1.2.3</version>@
@</dependency>@
h1. Getting started in less than 2 minutes
View
@@ -48,12 +48,26 @@
[1.2]
* REFACTOR: Moved scope inside OAuthConfig (breaks backwards compatibility)
* FEATURE: Added scopes to Facebook 2.0 Api
-<<<<<<< HEAD
* FEATURE: Added Plaintext signature for Yammer
* FEATURE: Added Twitter SSL endpoints (use TwitterApi.SSL.class)
[1.2.1]
* FEATURE: Added custom charset support to Request (thanks Eric Genet)
* FEATURE: Added support for Vkontakte (thanks dotbg)
-=======
->>>>>>> parent of 97f45d7... bounced version numbers for release
+ * FEATURE: Added Sohu Weibo, Netease Weibo & Sina Weibo Apis (thanks Arthur Wang)
+ * FEATURE: Added support for persistent Http Connections (thanks Craig Minton)
+
+[1.2.2]
+ * FIX: Added support for JDK 1.5. Issue #146 (thanks Sripathi Krishnan)
+ * FIX: Invalid character constant error message. Issue #137 (thanks Scott Scoble)
+ * FEATURE: Added a Api class to handle windows live authentication. Issue #135 (thanks Tomas Lin)
+ * FEATURE: Added refresh token feature for Yahoo! API. Issue #134 (thanks Aaron Foltz)
+ * FEATURE: Added support for Plurk API. Issue #130 (thanks Chia-Wei Li)
+ * FIX: Request.setConnectTimeout() and setReadTimeout() throw NPE. Issue #123 (thanks thepizzle)
+
+[1.2.3]
+ * FEATURE: Added default Content-Type header
+ * FEATURE: Sapo Api
+ * FEATURE: Plurk Mobile Api
+ * FEATURE: Kaixin and QWeibo Apis
+ * FEATURE: SimpleGeo Api
View
@@ -4,7 +4,7 @@
<groupId>org.scribe</groupId>
<artifactId>scribe</artifactId>
<packaging>jar</packaging>
- <version>1.2.0-patched</version>
+ <version>1.2.3</version>
<name>Scribe OAuth Library</name>
<description>The best OAuth library out there</description>
<url>http://github.com/fernandezpablo85/scribe-java</url>
@@ -63,11 +63,11 @@
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
- <source>1.6</source>
- <target>1.6</target>
+ <source>1.5</source>
+ <target>1.5</target>
</configuration>
</plugin>
- <!--plugin>
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<executions>
@@ -79,7 +79,7 @@
</goals>
</execution>
</executions>
- </plugin-->
+ </plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,40 @@
+package org.scribe.builder.api;
+
+import org.scribe.model.*;
+
+public class KaixinApi extends DefaultApi10a
+{
+ private static final String REQUEST_TOKEN_URL = "http://api.kaixin001.com/oauth/request_token";
+ private static final String ACCESS_TOKEN_URL = "http://api.kaixin001.com/oauth/access_token";
+ private static final String AUTHORIZE_URL = "http://api.kaixin001.com/oauth/authorize?oauth_token=%s";
+
+ @Override
+ public String getRequestTokenEndpoint()
+ {
+ return REQUEST_TOKEN_URL;
+ }
+
+ @Override
+ public String getAccessTokenEndpoint()
+ {
+ return ACCESS_TOKEN_URL;
+ }
+
+ @Override
+ public String getAuthorizationUrl(Token requestToken)
+ {
+ return String.format(AUTHORIZE_URL, requestToken.getToken());
+ }
+
+ @Override
+ public Verb getRequestTokenVerb()
+ {
+ return Verb.GET;
+ }
+
+ @Override
+ public Verb getAccessTokenVerb()
+ {
+ return Verb.GET;
+ }
+}
@@ -0,0 +1,43 @@
+package org.scribe.builder.api;
+
+import org.scribe.extractors.*;
+
+import org.scribe.model.*;
+
+import org.scribe.utils.*;
+
+import static org.scribe.utils.URLUtils.*;
+
+public class LiveApi extends DefaultApi20
+{
+
+ private static final String AUTHORIZE_URL = "https://oauth.live.com/authorize?client_id=%s&redirect_uri=%s&response_type=code";
+ private static final String SCOPED_AUTHORIZE_URL = AUTHORIZE_URL + "&scope=%s";
+
+ @Override
+ public String getAccessTokenEndpoint()
+ {
+ return "https://oauth.live.com/token?grant_type=authorization_code";
+ }
+
+ @Override
+ public String getAuthorizationUrl(OAuthConfig config)
+ {
+ Preconditions.checkValidUrl(config.getCallback(), "Must provide a valid url as callback. Live does not support OOB");
+
+ // Append scope if present
+ if (config.hasScope())
+ {
+ return String.format(SCOPED_AUTHORIZE_URL, config.getApiKey(), formURLEncode(config.getCallback()), formURLEncode(config.getScope()));
+ } else
+ {
+ return String.format(AUTHORIZE_URL, config.getApiKey(), formURLEncode(config.getCallback()));
+ }
+ }
+
+ @Override
+ public AccessTokenExtractor getAccessTokenExtractor()
+ {
+ return new JsonTokenExtractor();
+ }
+}
@@ -0,0 +1,47 @@
+package org.scribe.builder.api;
+
+import org.scribe.model.*;
+
+public class NeteaseWeibooApi extends DefaultApi10a
+{
+ private static final String REQUEST_TOKEN_URL = "http://api.t.163.com/oauth/request_token";
+ private static final String ACCESS_TOKEN_URL = "http://api.t.163.com/oauth/access_token";
+ private static final String AUTHORIZE_URL = "http://api.t.163.com/oauth/authorize?oauth_token=%s";
+ private static final String AUTHENTICATE_URL = "http://api.t.163.com/oauth/authenticate?oauth_token=%s";
+
+ @Override
+ public String getRequestTokenEndpoint()
+ {
+ return REQUEST_TOKEN_URL;
+ }
+
+ @Override
+ public String getAccessTokenEndpoint()
+ {
+ return ACCESS_TOKEN_URL;
+ }
+
+ @Override
+ /**
+ * this method will ignore your callback
+ * if you're creating a desktop client please choose this url
+ * else your can call getAuthenticateUrl
+ *
+ * via http://open.t.163.com/wiki/index.php?title=%E8%AF%B7%E6%B1%82%E7%94%A8%E6%88%B7%E6%8E%88%E6%9D%83Token(oauth/authorize)
+ */
+ public String getAuthorizationUrl(Token requestToken)
+ {
+ return String.format(AUTHORIZE_URL, requestToken.getToken());
+ }
+
+ /**
+ * this method is for web client with callback url
+ * if you're creating a desktop client please call getAuthorizationUrl
+ *
+ * via http://open.t.163.com/wiki/index.php?title=%E8%AF%B7%E6%B1%82%E7%94%A8%E6%88%B7%E6%8E%88%E6%9D%83Token(oauth/authenticate)
+ */
+ public String getAuthenticateUrl(Token requestToken)
+ {
+ return String.format(AUTHENTICATE_URL, requestToken.getToken());
+ }
+}
@@ -0,0 +1,39 @@
+package org.scribe.builder.api;
+
+import org.scribe.model.Token;
+
+public class PlurkApi extends DefaultApi10a
+{
+ private static final String REQUEST_TOKEN_URL = "http://www.plurk.com/OAuth/request_token";
+ private static final String AUTHORIZATION_URL = "http://www.plurk.com/OAuth/authorize?oauth_token=%s";
+ private static final String ACCESS_TOKEN_URL = "http://www.plurk.com/OAuth/access_token";
+
+ @Override
+ public String getRequestTokenEndpoint()
+ {
+ return REQUEST_TOKEN_URL;
+ }
+
+ @Override
+ public String getAuthorizationUrl(Token requestToken)
+ {
+ return String.format(AUTHORIZATION_URL, requestToken.getToken());
+ }
+
+ @Override
+ public String getAccessTokenEndpoint()
+ {
+ return ACCESS_TOKEN_URL;
+ }
+
+ public class Mobile extends PlurkApi
+ {
+ private static final String AUTHORIZATION_URL = "http://www.plurk.com/m/authorize?oauth_token=%s";
+
+ @Override
+ public String getAuthorizationUrl(Token requestToken)
+ {
+ return String.format(AUTHORIZATION_URL, requestToken.getToken());
+ }
+ }
+}
@@ -0,0 +1,28 @@
+package org.scribe.builder.api;
+
+import org.scribe.model.*;
+
+public class QWeiboApi extends DefaultApi10a
+{
+ private static final String REQUEST_TOKEN_URL = "https://open.t.qq.com/cgi-bin/request_token";
+ private static final String ACCESS_TOKEN_URL = "https://open.t.qq.com/cgi-bin/access_token";
+ private static final String AUTHORIZE_URL = "https://open.t.qq.com/cgi-bin/authorize?oauth_token=%s";
+
+ @Override
+ public String getRequestTokenEndpoint()
+ {
+ return REQUEST_TOKEN_URL;
+ }
+
+ @Override
+ public String getAccessTokenEndpoint()
+ {
+ return ACCESS_TOKEN_URL;
+ }
+
+ @Override
+ public String getAuthorizationUrl(Token requestToken)
+ {
+ return String.format(AUTHORIZE_URL, requestToken.getToken());
+ }
+}
@@ -0,0 +1,40 @@
+package org.scribe.builder.api;
+
+import org.scribe.model.*;
+
+public class SapoApi extends DefaultApi10a
+{
+ private static final String AUTHORIZE_URL = "https://id.sapo.pt/oauth/authorize?oauth_token=%s";
+ private static final String ACCESS_URL = "https://id.sapo.pt/oauth/access_token";
+ private static final String REQUEST_URL = "https://id.sapo.pt/oauth/request_token";
+
+ @Override
+ public String getAccessTokenEndpoint()
+ {
+ return ACCESS_URL;
+ }
+
+ @Override
+ public String getRequestTokenEndpoint()
+ {
+ return REQUEST_URL;
+ }
+
+ @Override
+ public String getAuthorizationUrl(Token requestToken)
+ {
+ return String.format(AUTHORIZE_URL, requestToken.getToken());
+ }
+
+ @Override
+ public Verb getRequestTokenVerb()
+ {
+ return Verb.GET;
+ }
+
+ @Override
+ public Verb getAccessTokenVerb()
+ {
+ return Verb.GET;
+ }
+}
@@ -0,0 +1,29 @@
+package org.scribe.builder.api;
+
+import org.scribe.model.Token;
+
+/**
+ * @author: Pablo Fernandez
+ */
+public class SimpleGeoApi extends DefaultApi10a
+{
+ private static final String ENDPOINT = "these are not used since SimpleGeo uses 2 legged OAuth";
+
+ @Override
+ public String getRequestTokenEndpoint()
+ {
+ return ENDPOINT;
+ }
+
+ @Override
+ public String getAccessTokenEndpoint()
+ {
+ return ENDPOINT;
+ }
+
+ @Override
+ public String getAuthorizationUrl(Token requestToken)
+ {
+ return ENDPOINT;
+ }
+}
@@ -0,0 +1,28 @@
+package org.scribe.builder.api;
+
+import org.scribe.model.*;
+
+public class SinaWeiboApi extends DefaultApi10a
+{
+ private static final String REQUEST_TOKEN_URL = "http://api.t.sina.com.cn/oauth/request_token";
+ private static final String ACCESS_TOKEN_URL = "http://api.t.sina.com.cn/oauth/access_token";
+ private static final String AUTHORIZE_URL = "http://api.t.sina.com.cn/oauth/authorize?oauth_token=%s";
+
+ @Override
+ public String getRequestTokenEndpoint()
+ {
+ return REQUEST_TOKEN_URL;
+ }
+
+ @Override
+ public String getAccessTokenEndpoint()
+ {
+ return ACCESS_TOKEN_URL;
+ }
+
+ @Override
+ public String getAuthorizationUrl(Token requestToken)
+ {
+ return String.format(AUTHORIZE_URL, requestToken.getToken());
+ }
+}
Oops, something went wrong.

0 comments on commit 228b7ac

Please sign in to comment.