I am building a simple search app through MIT AppInventor. I have had no problems in querying my spreadsheet shared as public on the cloud.
Suddenly, for no reason, my GET request to the HTTP fails with a response code of -1. I have looked everywhere but can't find an explanation for this -1 code.
Let me repeat that the same block of codes was working perfectly fine until this happened. Now I can't figure out what is going wrong. Any help will be much appreciated.
I solved this problem when I found out that my target spreadsheet link, which used to start with http:// was changed to https://. I found that my browser redirected me to https:// when I tried to run my query directly on the web. So changing that in my code fixed the issue.
I came across a similar issue recently. It used to work and I found out that my get request was being redirected to a login page being the session had expired.
I suggest you open the get request using the webviewer component (or activitystarter) to give you a better understanding of where the error is coming from.
Related
While making Android App I'm receiving such an error. It would be great if somebody can give me a prompt concerning my code.
Your URL is malformed. just add method of your URL.
for example add http:// in start of your URL. thats make your address like this: http://api.....
We are developing an app that should get data from the Moves app API.
When authorising our app on the mobile phone, we manage to do so successfully in the case in which we submit the PIN provided by the desktop link into the moves app:
https://api.moves-app.com/oauth/v1/authorize?response_type=code&client_id=<client_id>&scope=<scope>&state=<state>
In the case where I use the Mobile website / app link instead, this won't work:
moves://app/authorize?client_id=<client_id>&scope=activity%20location&state=<state>&redirect_uri=<redirect_uri>
Note: <redirect_uri>==encodeURIComponent("mymovesconnector:8081/callback").
The response we get from the Moves API is 400: {"error":"invalid_grant"}.
From the docs, it says that invalid_grant can happen if either:
the code in the request is not valid or
the code has expired (it’s valid for 5 minutes currently) or
the code has been revoked, because it was already used in an access token request (both successful and unsuccessful requests will revoke the code) or
you are missing the redirect_uri parameter when it’s required.
My checklist:
I guess this could have happened, but how/why should this code, provided over moves://, be different than the one provided through the https:// request? What control do I have over this?
not my case, since I'm using the code right away within less then a few seconds
if this might have happened, where could it happen other than through the redirect url?
I'm providing it always. It's always the same - also in the app settings on moves.
Can't figure out what I'm missing. Went through the docs many times, step by step. No success.
While writing down my question, I managed to figure out a solution to this problem.
The docs don't point out that response_type=code might also be used for the moves:// link. I tried to add this parameter, and it worked!
Note: this has been tested on a virtual android device only (Genymotion).
I searched SE's archives, google, directly ripped this off and ran it and I've been on it for like 6 hours now.
Based on the link above (jsOAuth Library) I wrote my code and when I run it on my android, the inAppBrowser (correctly) redirects me to the twitter page where I'm supposed to get my pin. But instead of the pin, it shows "there is no request token for this page... " error.
I even deleted and registered a new app under a different name and got a new pair of Consumer key/secret. But that too did not budge.
This could be a possible solution but even the Boilerplate example is not working. I guess I'm not getting my request token. Any help?
I'm using Twitter4J for posting some tweets.
When I try to post a tweet I open a webview with the authenticationURL to log in:
twitterRequestToken = twitter.getOAuthRequestToken(Constants.TWITTER_CALLBACK);
Intent i = new Intent(FutbolTvActivity.this, TwitterWebLoginActivity.class);
i.putExtra("URL", twitterRequestToken.getAuthenticationURL());
startActivityForResult(i, 1);
If I complete the process I get logged OK and can send the tweet.
The problem is that if I click on cancel button on login web page and I try to login again I receive the next exception on
twitter.getOAuthRequestToken(Constants.TWITTER_CALLBACK): No authentication challenges found
If I reuse the previous authentication URL the webview shows an error message saying this URL is too old.
Can anyone help me?
Finally, I found a solution:
At first time I was using:
twitter = TwitterFactory.getSingleton()
for getting the Twitter object. By this way the second time I call to getOAuthRequestToken() I get the error described above.
No, I'm using:
twitter = new TwitterFactory(configuration.build()).getInstance();
so I have different instances every time I start the related activity. By this way, I never call a second time over the same instance to getOAuthRequestToken() so I have no errors.
It might sound weird but try to set your time/date update automatically. Based on my previous experience this was the problem. When i set this and after the phone time is synced, everything works fine.
Changing Callback URL is not the reason, it take sometime to reset the keys. Check that your keys are correct and time is sync.. There is an issue arise few days ago which is fixed now. Make sure that any of the fields asking for URLs ("Website" and "Callback URL") are fully qualified, non-twitter.com domains.
May be it's possible your application name is already in use by another application. Experiment with different names and attempt to save again.
Check this link Temporary issue with creating applications
Check on your emulator, may be your device time is not sync. It won't work if your time is not sync.
The library is also updated.. Check this link Discussing API v1.1 and this too Issue with twitter: Unable to retrieve the access token. Status: 401.
Good luck with your project!
Hello all and first thing to apologize for my poor English.
I wanted to comment my problem on the attempt of the integration retweet on my android application.
So far I managed to authenticate with OAUTH and even I have been able to send a tweet.
My problem starts when I want to be able to send retweet from a ID that I have saved in a class.
I have tried almost everything, Ive been dozens of hours looking for information on this, but without knowing if I on the right track.
trying to create a getRetweetsById function
trying to make http GET to the address:
https://API.Twitter.com/statuses/retweets/21943348.json
... getting the same response in all cases
It doesnt work.
If someone could guide me which is the appropriate method and the steps i should follow I would be eternally grateful.
Thanks and best regards
hey try following code
Twitter mTwitter = TwitterFactory.getInstance();
mTwitter.retweetStatus("send ur id here");
thanks
santhu