Navigation Menu

Skip to content
This repository has been archived by the owner on Nov 5, 2022. It is now read-only.

'No authentication header information' when requesting photo data using OAuth authentication (GData Java v1.33) #174

Closed
GoogleCodeExporter opened this issue Apr 6, 2015 · 29 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
Execute this code using OAuth authentication...
final Link photoLink = gContact.getContactPhotoLink();
if (photoLink != null && photoLink.getEtag() != null) {
   GDataRequest request = service.createLinkQueryRequest(photoLink);
   request.execute();
   InputStream inputStream = request.getResponseStream();
}


What is the expected output? What do you see instead?
The expected output is the photo data should be retrieved but instead I get
this exception:
java.lang.NullPointerException: No authentication header information
at
com.google.gdata.util.AuthenticationException.initFromAuthHeader(AuthenticationE
xception.java:96)
at
com.google.gdata.util.AuthenticationException.<init>(AuthenticationException.jav
a:67)
at
com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataReque
st.java:563)
at
com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataR
equest.java:543)
at
com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.jav
a:535)
at
com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:514)
at
com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:
515)

The exception does not occur with the same logic but using
username/password authentication.


What version of the product are you using? On what operating system?
GData Java Client v1.33


Please provide any additional information below.
n/a

Original issue reported on code.google.com by yppir...@gmail.com on 17 Aug 2009 at 8:34

@GoogleCodeExporter
Copy link
Author

Just to verify, have you called service.setOAuthCredentials(oauthParameters, 
signer) 
before making the request?  That call is required in order to set the 
appropriate 
OAuth parameters.  Thanks!

Original comment by mon...@gmail.com on 25 Aug 2009 at 4:11

@GoogleCodeExporter
Copy link
Author

Yes, absolutely. We have logic that retrieves other contact details before the
request for the photo that relies on the 
service.setOAuthCredentials(oauthParameters,
signer) having been called and that is working correctly.

Here is roughly the logic leading up to the logic above:

ContactsService contactsService = new ContactsService("...");
GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();
oauthParameters.setOAuthConsumerKey(consumerKey);
oauthParameters.setOAuthToken(accessToken);
contactsService.setOAuthCredentials(oauthParameters, signer);
Query query = new Query(feedUrl);
ContactFeed resultFeed = contactsService.query(query, ContactFeed.class);
ContactEntry gContact = resultFeed.getEntries().get(i);

Original comment by yppir...@gmail.com on 26 Aug 2009 at 3:37

@GoogleCodeExporter
Copy link
Author

Thanks for the code snippet.  One more question, which signing method are you 
using, 
RSA or HMAC?

Original comment by mon...@gmail.com on 26 Aug 2009 at 3:46

@GoogleCodeExporter
Copy link
Author

RSA

Original comment by yppir...@gmail.com on 26 Aug 2009 at 5:07

@GoogleCodeExporter
Copy link
Author

monsur, can you tell me if this is a confirmed issue from your side and if so 
the
time frame for a resolution?

Original comment by yppir...@gmail.com on 27 Aug 2009 at 2:25

@GoogleCodeExporter
Copy link
Author

Hi I'm working on writing a verification sample now.  I'll update this thread 
with the 
results.  Thanks!

Original comment by mon...@gmail.com on 27 Aug 2009 at 7:23

@GoogleCodeExporter
Copy link
Author

Monsur, any update on this?

Original comment by yppir...@gmail.com on 8 Sep 2009 at 6:14

@GoogleCodeExporter
Copy link
Author

I actually have been experiencing a similar problem.  My code is roughly the 
same as
above, with some different variable names.  Also using RSA.  I would be 
interested in
seeing a solution.

Thanks

Original comment by agliddon@gmail.com on 23 Sep 2009 at 5:29

@GoogleCodeExporter
Copy link
Author

I have enabled 2-legged authorization and setting the OAuth parameters in the 
same
way to download Docs. I am getting the same exception

Original comment by Sajid1Qu...@gmail.com on 8 Oct 2009 at 6:30

@GoogleCodeExporter
Copy link
Author

I managed to fix the problem with 2-legged Auth, apparently, you need to ensure 
you
include the ?xoauth=<user>@<domain> with every single URL you send for queries,
creating, etc.

Original comment by agliddon@gmail.com on 8 Oct 2009 at 12:44

@GoogleCodeExporter
Copy link
Author

Has this issue been confirmed and has there been a resolution? thx, chris

Original comment by yppir...@gmail.com on 28 Feb 2010 at 9:59

@GoogleCodeExporter
Copy link
Author

I'm experiencing the same bug and even worse:
When adding any query parameters to a contact query, I get the same exception:
java.lang.NullPointerException: No authentication header information
        at 
com.google.gdata.util.AuthenticationException.initFromAuthHeader(AuthenticationE
xcept
ion.java:96)
        at 
com.google.gdata.util.AuthenticationException.<init>(AuthenticationException.jav
a:67)
        at 
com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataReque
st.ja
va:564)
        at 
com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataR
eques
t.java:543)

I'm using 2-legged auth with HmacSha.
I've experienced similar issues when using AuthSub with signed request token.

@Google: Anyone working on this?

Original comment by daniel.florey@gmail.com on 9 Mar 2010 at 3:46

@GoogleCodeExporter
Copy link
Author

I'm have the same issue, see this thread:
http://www.google.com/support/forum/p/Google+Apps/thread?tid=37b7fa2aa3741b5d&hl
=en

Thanks,

kw

Original comment by kw1...@gmail.com on 11 Mar 2010 at 7:49

@GoogleCodeExporter
Copy link
Author

In case my info inspires Google to get back to us - I'm using 3-legged OAuth to 
get 
gmail contacts.  Here's my code (after a gmail authorize and then a callback) -

GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters(); 
oauthParameters.setOAuthConsumerKey(CONSUMER_KEY); 
oauthParameters.setOAuthConsumerSecret(CONSUMER_SECRET);
OAuthSigner signer = new OAuthHmacSha1Signer(); 
GoogleOAuthHelper oauthHelper = new GoogleOAuthHelper(signer); 
oauthHelper.getOAuthParametersFromCallback(request.getQueryString(),oauthParamet
ers);
ContactsService myService = new ContactsService("Contacts Demo");
myService.setOAuthCredentials(oauthParameters, signer);
URL feedUrl = new URL("http://www.google.com/m8/feeds/contacts/default/full");
ContactFeed resultFeed = myService.getFeed(feedUrl, ContactFeed.class);

Running under eclipse with gdata 1.40.3, I get this -

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:564)
    at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse
(GoogleGDataRequest.java:563)
    at com.google.gdata.client.http.HttpGDataRequest.checkResponse
(HttpGDataRequest.java:536)
    at com.google.gdata.client.http.HttpGDataRequest.execute
(HttpGDataRequest.java:515)
    at com.google.gdata.client.http.GoogleGDataRequest.execute
(GoogleGDataRequest.java:535)
    at com.google.gdata.client.Service.getFeed(Service.java:1073)
    at com.google.gdata.client.Service.getFeed(Service.java:936)
    at com.google.gdata.client.GoogleService.getFeed(GoogleService.java:631)
    at com.google.gdata.client.Service.getFeed(Service.java:955)



Original comment by suzgjac...@gmail.com on 30 Mar 2010 at 12:01

@GoogleCodeExporter
Copy link
Author

Hi,
I'm experiencing exactly the same problem. I notice that Google is not really
interested in solving this issue rapidely therefor, I think it might be useful 
to
start testing other OAuth Java libs like e.g. Signpost. Did anyone already 
tried one?
Cheers,
Jef

Original comment by wauma002@gmail.com on 31 Mar 2010 at 7:35

@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

Looks like they've changed their documentation... I followed it and that fixed 
my 
problem! Check out the Java snippet under "Upgrading to an access token". The 
commented-out red line is what they used to have. The black line above it is 
new. 
(Never would have noticed this, but was changing my 3-legged to 2-legged and I 
went 
back to their doc.)

Original comment by suzgjac...@gmail.com on 27 Apr 2010 at 10:30

@GoogleCodeExporter
Copy link
Author

@suzgjacobs could you post a link? I'd be happy to try it, but I don't really 
know what snippet you're referring to, 
there's a whole bunch of information out there. 

Original comment by Tristan....@gmail.com on 28 Apr 2010 at 1:15

@GoogleCodeExporter
Copy link
Author

Thanks suzgjacobs.  Please take a look at the updated documentation under the 
section 
"Upgrading to an access token"
http://code.google.com/apis/gdata/docs/auth/oauth.html

I'm closing this issue now.  yppirtos, please check if this solves your 
problem.  If not, 
please reopen and provide more details about what auth flow you are using.

I would like to apologize for Google's slow response rate on this issue.  We 
will try to do 
better in the future.

Original comment by yan...@google.com on 28 Apr 2010 at 1:38

@GoogleCodeExporter
Copy link
Author

Original comment by yanivin...@gmail.com on 28 Apr 2010 at 1:40

  • Changed state: Invalid

@GoogleCodeExporter
Copy link
Author

I'll confirm this shortly. Thanks

Original comment by yppir...@gmail.com on 28 Apr 2010 at 1:48

@GoogleCodeExporter
Copy link
Author

Note that this resolution applies only to 3-legged OAuth.

For 2-legged OAuth please take a look at agliddon's comment to always include 
"xoauth_requestor_id" in every request.  However, if you are using the Query 
class, please 
take a look at known bug in Issue 263 (http://code.google.com/p/gdata-java-
client/issues/detail?id=263).

Original comment by yanivin...@gmail.com on 28 Apr 2010 at 3:28

@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

Hi, 
A have also run into the issue reported by suzgjacobs. I do not understand how 
the 
fix in the documentation is to be used @suzgjacobs could you share some code 
where 
this works? I see all the data (including the oauth access token) but for some 
reason these value are not being set in header (run into No authentication 
header 
information), help!

Original comment by asreddy74 on 27 May 2010 at 9:46

@GoogleCodeExporter
Copy link
Author

Looks issue only with using the contact service, works with getting the 
document list using gdata 1.41.1 libs

Original comment by asreddy74 on 8 Jun 2010 at 5:26

@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

Google fixed their documentation on this a while ago.  I used their sample code 
and it worked.

http://code.google.com/apis/contacts/docs/1.0/developers_guide_java.html

That was back with gdata 1.40.3

Original comment by suzgjac...@gmail.com on 5 Sep 2010 at 10:35

@GoogleCodeExporter
Copy link
Author

I'm still struggling with this.
3-Legged OAUTH was working fine until 2 days ago when I started getting a NPE : 
"No authentication header information".
Adding the "xoauth_requestor_id" does not help.
this is the code snippet 
ContactEntry contactEntry = 
ContactsServiceImpl.getContactsService().getEntry(new URL(id), 
ContactEntry.class);
The same instance of ContactsService works just fine to retrieve the list of 
all contacts from Google.

Original comment by k...@koma.be on 6 Mar 2011 at 1:40

@GoogleCodeExporter
Copy link
Author

Ok, figured it out, but the exception message is useless/irrelevant.

ContactsService myService = ... (init service)
// save entry in feed
ContactEntry = ... (init contactentry with some data)
ContactEntry savedEntry = 
ContactsServiceImpl.getContactsService().insert(postUrl, contactEntry);

// try to read the entry using the wrong URL : 
ContactEntry readEntry1 = ContactsServiceImpl.getContactsService().getEntry(new 
URL(savedEntry.getId()), ContactEntry.class); 
===> NPE : "no authentication header information".

// try to read the entry using the correct URL
ContactEntry readEntry1 = ContactsServiceImpl.getContactsService().getEntry(new 
URL(savedEntry.getEditLink().getHref()), ContactEntry.class); 
===> works


Original comment by k...@koma.be on 6 Mar 2011 at 2:01

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant