Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
987 views
in Technique[技术] by (71.8m points)

google api - Gmail atom feed with 2-legged OAuth receive 401 error

We are experiencing the issue of Gmail atom feed with 2-legged OAuth, an error message is "401 unauthorized".

The error message is like below.

<HTML>
<HEAD>
<TITLE>Unauthorized</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Unauthorized</H1>
<H2>Error 401</H2>
</BODY>
</HTML>

Until last week, we have no problem using Gmail atom feed. From this week, we are experiencing the issue even though we have a no change regarding Gmail atom feed and oauth. Now, this problem do not occurs on all users(50,000 accounts), but this issue is increasing more and more.

It seems that this problem is caused by Google's side.

Is there anyone who has same issue?

Source code is like below.

private GoogleOAuthParameters mOauthParameters; 
private OAuthSigner mSigner; 

private final String SCOPE = "https://mail.google.com/mail/feed/atom";

GoogleService service;

String result = null;

mOauthParameters = new GoogleOAuthParameters();
mSigner = new OAuthHmacSha1Signer();

mOauthParameters.setOAuthConsumerKey(CONSUMER_KEY);
mOauthParameters.setOAuthConsumerSecret(CONSUMER_SECRET);

service = new GoogleService("gmail","feed");
service.setOAuthCredentials(mOauthParameters, mSigner);
service.setConnectTimeout(timeOut);
service.setReadTimeout(timeOut * 5);

GDataRequest request = service.createFeedRequest(new URL(SCOPE +"?xoauth_requestor_id=" + email));
request.execute();
InputStream is = null;

try {
    is = request.getResponseStream();
    StringBuffer out = new StringBuffer();  
    byte[] buffer = new byte[4094];
    int readSize;
    while ( (readSize = is.read(buffer)) != -1) {
        out.append(new String(buffer, 0, readSize));
    }
    result = out.toString();
} catch (Exception e) {
    throw e;
} finally {
    is.close();
} 

I need your help.

Please check our source or other sample for gmail atom feed with 2-legged OAuth.

Regards.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Indeed, it seems to be a Google issue. I encourage you to report this to Google, using either the Report a Bug / Provide Feedback option from the (?) menu of the OAuth 2.0 Playground, or within Gmail (Send feedback option, from the cogwheel menu).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...