Note that there are some explanatory texts on larger screens.

plurals
  1. POOAuth - Invalid token: Request token used when not allowed
    primarykey
    data
    text
    <p>I'm trying to access Google's Documents List API 3.0 with OAuth 2.0 but I'm having some troubles with a 401 Error.</p> <p>After user have accepted, my code is the following:</p> <pre><code>GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters(); oauthParameters.setOAuthConsumerKey(CLIENT_ID); oauthParameters.setOAuthConsumerSecret(CLIENT_SECRET); oauthParameters.setOAuthToken(token); oauthParameters.setOAuthTokenSecret(tokenSecret); oauthParameters.setScope("https://docs.google.com/feeds/"); service = new DocsService("myapp"); service.setOAuthCredentials(oauthParameters, new OAuthHmacSha1Signer()); DocumentListFeed feed = service.getFeed(new URL("https://docs.google.com/feeds/default/private/full/?v=3"), DocumentListFeed.class); </code></pre> <p>Then, in the last line -getFeed()- throws the exception:</p> <pre><code>com.google.gdata.util.AuthenticationException: Token invalid - Invalid token: Request token used when not allowed. &lt;HTML&gt; &lt;HEAD&gt; &lt;TITLE&gt;Token invalid - Invalid token: Request token used when not allowed.&lt;/TITLE&gt; &lt;/HEAD&gt; &lt;BODY BGCOLOR="#FFFFFF" TEXT="#000000"&gt; &lt;H1&gt;Token invalid - Invalid token: Request token used when not allowed.&lt;/H1&gt; &lt;H2&gt;Error 401&lt;/H2&gt; &lt;/BODY&gt; &lt;/HTML&gt; </code></pre> <p>What's going on? On a static main test class works like a charm, but when I run it on the server this line does not works anymore. Any idea?</p> <hr> <p><strong>SOLVED</strong></p> <p>The access token needs to be retrieved this way, with a GoogleOAuthHelper, not with the GoogleOAuthParameters directly:</p> <pre><code>String accessToken = oauthHelper.getAccessToken(oauthParameters); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload