连接到Window Live Oauth时java.net.MalformedURLException

时间:2011-11-27 13:36:56

标签: java oauth oauth-2.0 scribe

我正在使用scribe java API进行Oauth服务,我能够与Gmail和Facebook完美配合,但是当谈到Window live服务时,我很震惊。 我遵循标准代码whihc对其他服务非常好。我可以从窗口实时获取访问令牌 但当我试图访问该服务以获取用户配置文件时,我正在

java.net.MalformedURLException

这是异常日志消息

org.scribe.exceptions.OAuthException: Problems while creating connection.
    org.scribe.model.Request.send(Request.java:71)
    org.scribe.model.OAuthRequest.send(OAuthRequest.java:12)
......
......

java.net.MalformedURLException: no protocol: "https://apis.live.net/v5.0/me?access_token=EwAoAq1DBAAUlbRWyAJjK5w968Ru3Cyt%5C%2F6GvwXwAAdfi2SDJuwJlMd29Za96amS5o2UFyXbtnIZglVJKxdimcPb2yYie966goCS2%2ByCjrWBpgUUUphkhYwFyFiN8I2J3pdyg4IQlbG%2BD8U%5C%2F9q5M5iU1q6niqYldYYOyq3ZpNw95l3oFdefQBlnEesequMhHhTVw%2B0ku93xc06lnULgYbVubTWqT8zBzwgHRie93CSDl1wUWQAYe2TzAAk9iIsBvmTmiICdWFrFpZrmpBS3VOec9zdarXuloaXI1IEPA5fDT%2B04RF8uUi1AukmRfjr%2B4C2J8fg8wbRQguMlZNLwG9fleixl2MLcA18ZOkHS%2Bu2eS5BcDYzCfOI8YJ9zf9IGUDZgAACLp7RJwAG8gk%2BAAFtLOh0pYNNGb3AtyjyurJowo014DLmKLLQfjeB0Lz3Nnwd0oBSv0g0qAT8qvdlLlVNyvgg3weqYiR%2BxD%2Bl8kX0SFBX7unVAkiloyqme7D4lNSM25wnJJrmc8wgop5x12MxwtuAOx3IXaNijCkyqtyVRfpU%2BVYv%5C%2FyH5JRuKOEia%2BX00%5C%2FEeWOXOP%5C%2F1yL9zYpRDaBpgOlZ7gBY6Q45buBjaGWsAi4Zg7QSDZeaFkMrIkVaWhhOdpNArXfUnDWAezlLqQZF0Otl8%5C%2F9%2BP3hel0mR7noFaMG0o57kV%2Bnm%2BhzF8LgCZleJCVdxC19ZmhrLM%5C%2FKTTEkAYHQWXhLQAA
    java.net.URL.<init>(Unknown Source)
    java.net.URL.<init>(Unknown Source)
    java.net.URL.<init>(Unknown Source)
    org.scribe.model.Request.createConnection(Request.java:81)
    org.scribe.model.Request.send(Request.java:62)
    org.scribe.model.OAuthRequest.send(OAuthRequest.java:12)
    com.raisonne.oauth.action.OAuthCallbackHandlerAction.OtherCallBackHandler(OAuthCallbackHandlerAction.java:101)
    com.raisonne.oauth.action.OAuthCallbackHandlerAction.execute(OAuthCallbackHandlerAction.java:50)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    java.lang.reflect.Method.invoke(Unknown Source)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
    com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
    org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:270)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:498)
    org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)

我无能为力的API出了什么问题,因为在调试其他应用程序时它正在创建相同的URL模式

connection = (HttpURLConnection) new URL(effectiveUrl).openConnection();

这是API中引发异常的行

2 个答案:

答案 0 :(得分:2)

首先,这不是使用HttpURLConnection的问题,因为:

  1. HttpsURLConnectionHttpURLConnection

  2. 的子类型
  3. 如果是这样的话,肯定会抛出一个类演员 例外

  4. 检查您传递的网址,我猜是看起来像这样:

    "\"https://..."(请注意,您在网址上有前一个"但不是尾随的一个

答案 1 :(得分:-1)

由于您的网址使用“https”协议,因此您必须使用HttpsURLConnection课程,而不是HttpURLConnection课程。