I upgraded to version 1.0a and when revoking permission I have been
receiving the following error when attempting to authorized access
token
      Caused by: java.io.IOException: Server returned HTTP response
code: 400 for URL

This declared on http://code.google.com/apis/accounts/docs/OAuth_ref.html
     Note: The return of a verification code does not indicate that a
request token has been authorized. If a request token has not been
authorized, then requests to exchange it for an access token will
fail.

However, instead of getting the response content ("The request token
is invalid.") which can be acquired by manually trying out the request
URL in a browser OAuthHttpClient.getResponse() instead throws the
IOException above with the 400 code leaving the developer to fumble
and debug.

After finding the following link
     
http://www.coderanch.com/t/433447/Streams/java/HttpsURLConnection-Reading-Body-Response-when
I have tried patching with the following


    public String getResponse(URL url) throws OAuthException {
        try {
            HttpURLConnection connection = (HttpURLConnection)
url.openConnection();
            connection.connect();

            InputStream _is;
            if (connection.getResponseCode() < 400) {
                _is = connection.getInputStream();
            } else {
                /* error from server */
                _is = connection.getErrorStream();
            }

            BufferedReader in = new BufferedReader(new
InputStreamReader(_is));
            String inputLine;
            StringBuilder response = new StringBuilder();
            while ((inputLine = in.readLine()) != null) {
                response.append(inputLine);
            }
            in.close();

            if (connection.getResponseCode() >= 400) {
                throw new IOException(response.toString());
            }

            return response.toString();
        } catch (IOException e) {
            throw new OAuthException("Error getting HTTP response",
e);
        }
    }

At least this way you can interrogate the exception to find out what
happened.


On Aug 18, 12:48 pm, n0_fixed_ab0de <[email protected]> wrote:
> It looks like the header "WWW-Authenticate" is not available. Is this
> a bug and if so is it being looked at?
>
> /**
>    * Constructs a new AuthenticationException instance based upon
>    * the contents of a WWW-Authenticate header as described by
>    * RFC2617.
>    */
> ......
>   public AuthenticationException(HttpURLConnection httpConn)
>       throws IOException {
>     super(httpConn);
>     initFromAuthHeader(httpConn.getHeaderField("WWW-Authenticate"));
>   }
>
> On Aug 17, 4:37 pm,n0_fixed_ab0de<[email protected]> wrote:
>
> > After revoking access permission from a domain subsequent OAuth
> > requests to access the service from this domain results in the
> > following:
>
> > java.lang.NullPointerException: No authentication header information
> >        at
> > com.google.gdata.util.AuthenticationException.initFromAuthHeader
> > (AuthenticationException.java:96)
> >        at com.google.gdata.util.AuthenticationException.<init>
> > (AuthenticationException.java:67)
> >        at
> > com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse
> > (HttpGDataRequest.java:563)
> >        at
> > com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse
> > (GoogleGDataRequest.java:543)
> >        at com.google.gdata.client.http.HttpGDataRequest.checkResponse
> > (HttpGDataRequest.java:535)
> >        at com.google.gdata.client.http.HttpGDataRequest.execute
> > (HttpGDataRequest.java:514)
> >        at com.google.gdata.client.http.GoogleGDataRequest.execute
> > (GoogleGDataRequest.java:515)
> >        at com.google.gdata.client.Service.getFeed(Service.java:1034)
> >        at com.google.gdata.client.Service.getFeed(Service.java:976)
> >        at com.google.gdata.client.GoogleService.getFeed
> > (GoogleService.java:662)
> >        at com.google.gdata.client.Service.query(Service.java:1136)
> >        at com.google.gdata.client.Service.query(Service.java:1077)
>
> > I was hoping to see something a bit more explicit telling the
> > authentication request had failed.
>
> > Is this normal and what should be expected?
> > And if so can I reliably interpret this as meaning permission has been
> > revoked?
>
> > Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Data Protocol" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to