I can't get Oauth to work with Twitter. I have tried the following (all result in the same 401 error):
jTwitter (using the default OauthSignpostClient)
jTwitter using the commonshttp library (CommonsOauthProvider) instead of the "DefaultOauthProvider"
jTwitter using the OauthScribeClient (instead of the OauthSignpostClient)
oauth-signpost (by itself... no jTwitter)
Twitter4J
http://code.google.com/p/agirardello/
http://dev.bostone.us/2009/07/16/android-oauth-twitter-updates/
http://github.com/kaeppler/signpost-examples/blob/master/OAuthTwitterExample/src/TwitterMain.java
I've tried my own implementation and copy/pasted the sample code from each of the sites, and nothing seems to work. I'm also 100% sure I also downloaded and included any dependencies (where needed).
Here's the interesting part. Using jTwitter and the oauth-signpost library, I can initiate a connection to Twitter, open a browser window for the user, have them log-in and generate a PIN for my app. When the app goes to post a status update however, (using the pin, and the stored access token and token secret), the 401 error pops up. All other things I've tried won't even let me open a browser window and ask the user to generate a PIN (they die with the 401 error on the request for the "request token").
Please help. Thanks
I don't know if it will help you much with Android, but this post on Twitter OAuth by Chris Shiflett just came up on my interwebs.
First of all for OAuth you need to register your application with twitter I am assuming you have registered it. Now in case of desktop and mobile application you need request twitter for custom callback URL, as default callback url just works only for web apps. Once twitter approves requested call back URL , it will work .
But there is workaround, rather than OAuth request twitter for xAuth by submitting details of your applications. Then if twitter approves it , you can uses xAuth which works almost similar to OAuth.
Make sure your application had read&write access when you created it....
Related
I am trying firebase twitter login in android app and it gives this error.
E/Twitter: Invalid json: <?xml version="1.0" encoding="UTF-8"?><errors><error code="415">Callback URL not approved for this client application. Approved callback URLs can be adjusted in your application settings</error></errors>
If firebase and app.twitter callback url are the same, it gives this error. If i change callback url it works but this time I don't see authentication info(user email etc.) in firebase console. I need to use https://appname.firebaseapp.com/__/auth/handler this on app.twitter for auth but it gives error. Any solution thanks in advance.
Latest solution
Just add twittersdk:// as one callback URL on your twitter app setting https://apps.twitter.com/ and it will work as a magic.
Most oauth providers require the redirect uri (which I suppose is the callback url here) to be predefined, for safety reasons. You say if you change it, you don’t get this error, but you don’t mention what the change is that you’re making. Either way, I think you answered your own question, you should change it and then work out why your next problem with user info is occurring, which is at a later stage in the oauth process.
Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.
I have researched the most popular questions on SO already (Question 1, Question 2, Question 3, Question 4, and Question 5)... None of them help with my situation.
I have the application settings laid out like this...
App Domains: azeverything.com
Sandbox Mode: Disabled
Website with Facebook Login
Site URL: http://azeverything.com
****App Domains*** requires that no protocol be identified and Site URL requires that a protocol be identified.*
I have tried using www.azeverything.com and that didn't work either. Everything seems to match up. By the way, this is a WP site. I'm not developing locally either. It's all live.
Try to check at Settings > Advanced. At Valid OAuth redirect URIs, make sure you have a correct domain.
Hope it works.
You need to add the URL to your app:
Go to the app, you want for user login, on the Facebook Developers page
Click on the settings tab
Click add platform
Select Website
After selection it will ask for some details such as URL for your website which uses login with facebook feature, fill the form and submit it
That's all and you are done. Make sure that the app's URL is the same from where you're logging in.
Under Basic settings:
Add the platform - Mine was web.
Supply the site URL - mind the http or https.
You can also supply the mobile site URL if you have any - remember to mind the http or https here as well.
Save the changes.
Then hit the advanced tab and scroll down to locate Valid OAuth redirect URIs its right below Client Token.
Supply the redirection URL - The URL to redirect to after the login.
Save the changes.
Then get back to your website or web page and refresh.
This is a basic breakdown for slow people like me, and I didn't see this mentioned before.
The "redirect uri" isn't the place where you're redirecting to, but where it's coming from.
Say you have your app at http://myFBapp.com listening to /auth/facebook, and after they log in, redirecting them to /UserLoginHooray. The "Valid OAuth redirect URIs" should read http://myFBapp.com/auth/facebook, not http://myFBapp/UserLoginHooray.
Explanation:
HTTP Requests that have been redirected (302) include the original address in the header, so Facebook is merely putting a very basic layer of security on the request.
I chased my tail on this issue for hours. My coder and I could login with FB without a problem but my wife couldn't. She would get this topic's subject message. I tried every setting and URL that I could think of for my Lavarel app.
My issue was that my wife was signing in from:
http://www and we were using http://
A short trip to CPanel and a redirect fixed that. Hope this helps someone!
For Lavarel these FB app settings worked for me:
Settings/Basic - App Domain: mydomain.com , Site URL: http://mydomain.com/login.
Settings/Advanced - Client OAuth Login: Yes.
Settings/Advanced - OAuth redirect URIs: http://mydomain.com , http://mydomain.com/login.
App Details/App Center listed platforms = No. I'm only using the login for now.
I have a website with facebook login.
It has been stable and working for months.
No code change has happened for weeks.
Then, suddenly, the facebook login gives an error message:
Error
Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.
After debugging "for awhile", I reset my facebook app secret and it started to work again!
Michael Blackburn's answer helped me resolve my issue, but I want to give more detail on my fix.
I have a php app that posts to a user's FB page.
I own two domains:
http://app.my-web-app.com
http://app.mywebapp.com (no hyphen)
I built my site off the first domain because it read better IMHO (at least it did at the time).
Some users typoed the url so I bought the second one with no dashes for that reason.
So, one of my users was having the "Given URL" error.
Turns out he was going to http://app.mywebapp.com and the rest of them were going to http://app.my-web-app.com
I fixed everyone by adding all possible redirect URIs:
Granted, there are 100 better ways to implement this, but here is the workaround for now.
1.Make Sure Website Url and platform added, if not then visit https://developers.facebook.com/quickstarts/ then Select
Platform -> Setup SDK -> Website Url And so on..
Note: website url can't be like this : https://www.example.com just remove www and make it simple and working ;)
2.Goto App Dashboard -> Setting -> Click on Advanced Tab then go to bottom of the page and enable Embedded Browser OAuth Login
and leave Valid OAuth redirect URIs blank and Save it
I found Valid OAuth Redirect URIs under PRODUCTS then Facebook Login > Settings not as everyone is stating above. I am supposing this is a version issue.
It still didn't work for me. I guess I really have to add Android Platform rather than just the Website. This is annoying because my app is still in development mode :(
UPDATE: I'm using Expo to develop my react-native app and used info provided here: https://developers.facebook.com/apps/131491964294190/settings/basic/ to set up the Android and iOS platforms. This resolved the issue for me.
Sometimes this error occurs for old javascript sdk. If you save locally javascript file. Update it. I prefer to load it form the facebook server all the time.
Go to facebook developer dashboard
Select settings -> select WEB(for website) -> Add platform
Add your site URL.
This should resolve your issue.
So... facebook distinguishes pretty harshly between http and https in your app. This is just another small thing to check if you run into trouble.
I solved this issue by specifying correct site URL in my App Settings.
It works fine now. You have to specify your website Url such as http://www.xyz.com/
Under advanced tab make sure "Valid OAuth redirect URIs" contains valid URI or leave it empty(not recommended)
"http://example.com/"
instead of
"http://www.example.com"
sometimes you need to check your code (the part of redirect)
$helper = new FacebookRedirectLoginHelper('https://apps.facebook.com/xxx');
$auth_url = $helper->getLoginUrl(array('email', 'publish_actions'));
echo "<script>window.top.location.href='".$auth_url."'</script>";
if any changes happens there (for example, the name of your application "https://apps.facebook.com/xxx" in relation the application settings in facebook, you will get the above error
For Android Developers,
Make sure you have enabled Facebook Login inside the Products list inside Dashboard of your Facebook project app and have added all the required details as you go through the whole flow.
The login should work without giving the same error.
I need to post tweets not only with text but also with images.
I already tried socialauth library, which doesn't support images in tweets.
What is best way to implement twitter sharing from my Android application?
Should work fine with scribe, haven't tested this sample in a while and I know twitter shut off some of its older APIs but I think the example still works fine.
Once you get your auth token you'll still do an OAuthRequest like my example, but the verb will be POST and you'll need to attach a body. You'll use this API instead of verify_credentials https://dev.twitter.com/docs/api/1.1/post/statuses/update_with_media
http://schwiz.net/blog/2011/using-scribe-with-android/
This is driving me MAAAADDDD
I'm trying to implement "Log In With PayPal" on Android.
I'm using this sample app to try to get the login screen to show up. https://github.com/SeraphimSerapis/PayPal-Access-Android-Example
I have created an app on the https://devportal.x.com/ website as instructed, I just want to use OAuth 2.0, I did all the settings, no luck.
Also, followed the answer in here https://stackoverflow.com/a/16199165/546439 i.e. created a seller account on developers.paypal and clearly chosen login with paypal access and credentials etc, still no luck
I don't even know whether I should get the credentials from x.com or paypal.com, each of them give the same options but they return different keys, I am so lost.
Please help.
UPDATE: added auth URL I am sending
all of these are not working
https://identity.x.com/xidentity/resources/authorize?client_id=AXbPkxDchMYBBAWn2UExvLytvvbJDDXn6u-9nWNgF_J7SZmwQkdDTwxHkuKe&scope=https://identity.x.com/xidentity/resources/profile/me&redirect_uri=http%3A%2F%2Faccess.com%2Findex.php&response_type=code
https://identity.x.com/xidentity/resources/authorize?client_id=ATL6BhBqBYAwJnolhJDT04El5GtxxDzTMAQEb5kkCdZVDrMr_v5bWlPpw7nN&scope=https://identity.x.com/xidentity/resources/profile/me&redirect_uri=http%3A%2F%2Faccess.com%2Findex.php&response_type=code
https://identity.x.com/xidentity/resources/authorize?client_id=6956fcaf5d9fb4bbea22af7ce7f4cc7a&scope=https://identity.x.com/xidentity/resources/profile/me&redirect_uri=http%3A%2F%2Faccess.com%2Findex.php&response_type=code
This error meaning that you are sending wrong client_Id "or not sending it" within the URI asking for token which is sent to authorize URL /authorize?client_id={client_id}, please share your URI to check it.
client_id string Unique client identifier obtained through the
application registration process. Required.
from https://developer.paypal.com/webapps/developer/docs/api/
I stumpled across a similar problem. I already hat an REST app running and tried to implement PayPal Login. Everytime I tried to use the sandbox client_id I got the same error message as you.
Took me some time to figure out, that, in my own stupidity, I tried to call
https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize
instead of
https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize
Now everything works for me
I had faced the same issue, I know this is a old issue and my solution may not be of much help. But I felt like sharing my fix.
I use devise for authentication and I wanted to implement PayPal login.
I configured omniauth for paypal inside config/initializers/devise.rb file. But by default the authentication path was "https://www.paypal.com/". As #Ello mentioned in his answer we need "https://www.sandbox.paypal.com/" url path for sandbox.
Then I figured out that we can change the url path to sandbox by passing sandbox as true in omniauth configuration.
So this is what I did in devise config file to resolve the issue
config.omniauth :paypal, PAYPAL_CLIENT_ID, PAYPAL_APP_SECRET, scope: PAYPAL_PERMISSIONS, sandbox: true
I would like to integrate Twitter into my Android application so that I can post messages to Twitter.
It really depends on how you want the interaction to work. You can:
Use their API (helped by a library such as twitter4j, as suggested by Heiko Rupp), or
Find a way to integrate with the Twitter app, although there is no published protocol for this as far as I know. This is also not a good idea because many people use other apps such as Twidroyd, TweetDeck and so on, but it would definitely be cool, or
If you don't expect the user to do this very often, you can just open up http://twitter.com/?status=<what-to-tweet> using a simple intent.
Method 3 can be easily described here:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("http://twitter.com/?status=" + Uri.encode(message)));
startActivity(i);
You can also combine 2 and 3. You can try a few known apps (official Twitter, TweetDeck, ...) and if all of them fail (because they're not present or because they have been updated and broke the protocol) you resort to opening up the browser.
Also note that it might be possible for method 3 to actually launch an app instead of the browser (or at least give the user a choice between the two), if the app handles the correct intents.
Another thing worth mentioning is that it's very possible that you will not be able to integrate with any Twitter apps. What I've said here is purely hypothetical, I have no idea whether these apps support such integrations. You should consult each app and see if they expose some intents that you could use. If they don't, you can still hack around a little and you might find them, but that will be unreliable because they will most probably break after a couple of updates.
You could use the twitter4j library to talk to twitter. Since Twitter has changed over to oAuth, the initial authentication is not trivial.
Basically you need to register your app with Twitter (go to your profile and then to the developer page to register your app - you will then get consumer token+secret). Then follow this example to authenticate with Twitter.
You may have a look at Zwitscher (rev 0.65, code of oAuth has not been updated for the nw internal changes after 0.65), which is an open source Twitter client for a larger example.
You may have a look at one of my examples of how to get Sign-in with twitter working on android.
It uses twitter4j, and with slight modification, you can make it post tweets too!
find it here.
UPDATE: there's one question specific to this issue: twitter,update status
I use twitter4j and oauth-signpost to create facebook like oauth authorization (webview dialog). Checkout this post
You can send the appropriate Intent to start the default twitter application
You can do this without Twitter4j, thus avoiding the massive headache of implementing the OAuth flow.
String tweetText = "We be tweetin!";
String url = "twitter://post?message=";
try {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url + Uri.encode(text)));
startActivity(i);
} catch (android.content.ActivityNotFoundException e) {
Toast.makeText(this, "Can't send tweet!", 2).show();
}
Other supported twitter:// urls are listed here.
If the user has the Twitter App installed on their device it'll open it directly to a share view. When cancelled or shared it'll return direct to your App. Super simple. Similar to how iOS handles sharing now (with Facebook and Twitter integration).
This doesn't handle cases where the user uses another App as their primary Twitter client.