We ran into the problem of submitting a Gmail atom with two-way OAuth, error message "401 unauthorized."
The error message is as follows.
<HTML> <HEAD> <TITLE>Unauthorized</TITLE> </HEAD> <BODY BGCOLOR="#FFFFFF" TEXT="#000000"> <H1>Unauthorized</H1> <H2>Error 401</H2> </BODY> </HTML>
Until the last week, we have no problems using the Atom Gmail feed. This week we have been faced with this problem, although we have no changes regarding the submission to the Gmail channel and oauth. Now this problem does not occur for all users (50,000 accounts), but this problem is increasing.
This problem appears to be caused by Google.
Does anyone have such a problem?
The source code is as follows.
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 out our source or other gmail atom feed using two-way OAuth.
Sincerely.
source share