Invalid signature. Expected JAVA Signature Base String

We use this piece of code to send an aweber request through oAuth

long unixTime = System.currentTimeMillis() / 1000L; OAuthRequest request1 = new OAuthRequest(Verb.GET,"https://api.aweber.com/1.0/accounts/1111/lists/1111/subscribers", service); request1.addBodyParameter("ws.op", "create"); request1.addBodyParameter("email", " account@gmail.com "); request1.addBodyParameter("name", "ankur"); request1.addBodyParameter("oauth_token_secret", "mysecret"); request1.addBodyParameter("oauth_token", "mytoken"); request1.addBodyParameter("oauth_consumer_key", "mykey"); request1.addBodyParameter("oauth_signature_method", "HMAC-SHA1"); request1.addBodyParameter("oauth_nonce", "secret"); request1.addBodyParameter("oauth_timestamp", String.valueOf(unixTime)); service.signRequest(accessToken, request1); Response response1 = request1.send(); // Create a reader to read Twitter stream BufferedReader reader1 = new BufferedReader(new InputStreamReader(response1.getStream())); String line; while ((line = reader1.readLine()) != null) { System.out.println(line); } 

But we get it back

 { "error": { "status": 401, "documentation_url": "https://labs.aweber.com/docs/troubleshooting#unauthorized", "message": "Invalid signature. Expected signature base string: GET%26https%3A%2F%2Fapi.aweber.com%2F1.0%2Faccounts%2F1111%2Flists%2F1111%2Fsubscribers%26oauth_consumer_key%3Dmykey%26oauth_nonce%3Dnonce%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1461676770%26oauth_token%3Dmytoken%26oauth_version%3D1.0%20https%3A%2F%2Flabs.aweber.com%2Fdocs%2Ftroubleshooting%23unauthorized", "type": "UnauthorizedError" } } 

Invalid signature. Expected Database String

I checked my signature, hers. I don’t know why his show is different.

UPDATE - 1:

Many guys say that my key and access token are invalid, but in my code I hit the first URL of the account, after which I try to hit another.

like this

  OAuth1AccessToken accessToken= new OAuth1AccessToken("oauth_token","oauth_token_secret","oauth_token_secret=oauth_token_secret&oauth_token=oauth_token"); final OAuthRequest request = new OAuthRequest(Verb.GET, ACCOUNT_RESOURCE_URL, service); service.signRequest(accessToken, request); final Response response = request.send(); System.out.println("Got it! Lets see what we found..."); System.out.println(); System.out.println(response.getBody()); System.out.println(); System.out.println("Thats it man! Go and build something awesome with AWeber and ScribeJava! :) 11111111"); 

and here is log

  Got it! Lets see what we found... {"total_size": 1, "start": 0, "entries": [{"http_etag": "\"8c4c161ee1fd3dfg596911c82e9f2feff145907dec2-ca5feee2b7fbb6febfca8af554fg1541ea960aaedb\"", "lists_collection_link": "https://api.aweber.com/1.0/accounts/xxxx/lists", "self_link": "https://api.aweber.com/1.0/accounts/xxxx", "resource_type_link": "https://api.aweber.com/1.0/#account", "id": xxxx, "integrations_collection_link": "https://api.aweber.com/1.0/accounts/xxxx/integrations"}], "resource_type_link" : "https://api.aweber.com/1.0/#accounts"} 

After that I run my top code. So something is wrong with my key, why does it work for the first part of the code?

+5
source share
2 answers

Root Cause Analysis: Invalid Signature

This error occurs when the signature of your request is not as expected. Common causes of this error are incorrect or missing token private keys ( either consumer, request token, or access token ) or incorrect OAuth 1.0A implementation in your applications.

Here access token has an expiration time. after the expiration, the access token will not work.

There is another limitation. There are limits on the number of refresh tokens to be released; one limit for each client / user combination, and another for each user for all clients.

So, in your case, it can also happen that you have already overcome the limit of creating an update token.

For the solution, you can execute my other answer: Google Play Developer API - request purchase token returns an invalid value


To fix the problem, you can do the following:

  • Make sure your consumer secret is correct by logging into your lab account, and copy and paste the user key into your application.
  • Issue new request tokens and / or use tokens and try again.
  • Verify that the application uses OAuth 1.0A correctly with respect to the server’s base line.
  • Refer to RFC5849 OAuth 1.0A Specification Section 3.4.1 for more details.
+3
source

Invalid consumer key

What it is? This error occurs when your customer key is invalid. The most common cause of this error is a typographical error in the client key copied from your labs account.

Troubleshooting Checklist Copy and paste your customer key from your account into your application and try again. If you use the distributed authentication method, make sure that you correctly parse the consumer key from the returned authorization code. https://labs.aweber.com/docs/troubleshooting#unauthorized

-1
source

Source: https://habr.com/ru/post/1247952/


All Articles