I;m newbie to Android Development , i'm working in a small project that helps me to learn Android , it;s a Twitter Client , i'm using OAuth for authenticating the user to use Twitter's services and not using any callback urls, so i have to forward the user to a specific Twitter URL to get the PIN to continue the authenticating processes , after forwarding the user to the URL i wanna to force him to go back to my preferences activity write the PIN to continue the process , how this can be achieved ? any new ideas are welcomed..
I have an example here using oauth to login to twitter on android without using the pins.
Not sure if this is the same but there is a tutorial on how to do the whole end-to-end twitter OAuth integration here with Twitter4J, and that returns Twitter to the activity to write the access details to the SharedPreferences by using a Callback url and handling the writing of the details in the original activity onResume() method.
It passes the Callback URL to the request to retrieve the tokens and then there is an Intent-Filter in the Manifest XML to return the request to the calling Activity.
Hope it helps.
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.
I have folowing scenario.
My client (local tv publisher) publishes some article and embeds tweet in it. ID of embeded tweet is sent through api to android application.
On android side i have integrated Fabric/TwitterKit and by following steps on twitter developers page i managed to show tweet in my android app on (i admit) easy way (Show tweet exp).
Now i have published application to Alpha and noticed one "little" problem :-). TwitterKit was using my local twitter account to authenticate and to show tweets. If you dont have Twitter application installed or signed out of it, my show tweet functionality wont work..
This is TwitterLogin explanation for obtaining TwitterKit auth token:
"When attempting to obtain an authentication token, the Kit will use the locally installed Twitter app to offer a single sign-on experience. If the Kit is unable to access the authentication token through the Twitter app, it falls back to using a web view to finish the OAuth process.
The simplest way to authenticate a user is using TwitterLoginButton, inside your layout..."
What i want is to simply show content of tweet by given tweetID. No sending tweets, or any other action with it. Just show data from given url. Is it possible without authentication, or what should i do now, so that current implementation works without user authentication (or with some non-single-signon-inside-app authentication)
Thank you.
UPDATE 1:
I have created MyApp extends Application class, and placed code below inside onCreate method. In application tag inside AndroidManifest file, added line:
AndroidManifest.xml
android:name=".MyApp"
onCreate:
TwitterAuthConfig authConfig =
new TwitterAuthConfig(DeveloperKey.TWITTER_CONSUMER_KEY, DeveloperKey.TWITTER_CONSUMER_SECRET_KEY);
Fabric.with(this, new TwitterCore(authConfig),
new TweetUi());
It works so far, but i am not sure if this implementations is valid.
DeveloperKey.TWITTER_CONSUMER_KEY and DeveloperKey.TWITTER_CONSUMER_SECRET_KEY are static values obtained from application created at apps.twitter.com.
You need to use Application Only authentication.
That will generate a set of keys which can be used by the application. It won't be able to post messages to Twitter (because no user is associated with it) but you will be able to read Tweets.
If you build the keys into the app, your user won't have to sign in.
All the documentation is at https://dev.twitter.com/oauth/application-only
I have a website which uses nodejs and passportjs for authentication. I now need to use this system to login with my android application. I am unsure as to the correct way to proceed. Do I simply use the website and load it in a web view itself? Is this the correct way to do ? Otherwise I would have to probably send the username and password for the first time and establish a token. Are there any libraries with android support which do this ? Could someone please help me out?
Follow the following steps and hopefully you will get your app to do what you want:
Step 1: Create a Login View in your android app that allows users to enter email/username and password.
Step 2: Secondly, get their username/email and password (encrypt the passwords) and then:
Step 3: Create an AsyncTask - you can learn how to do that using Android Documentation. In that AsyncTask,
Step 4: Using HttpRequest, make a POST request to your website by passing a long the user credentials.
Step 5: Since you already know how to handle login processes on the site, you can do the same using the http request from Android. Then if the user is successfully logged in,
Step 6: Simply return a JSON response to verify that a user was successfully logged in or not.
Once they are logged in, you can redirect them to their profile or protected resources as you wish.
I hope this helps.
I am tring to invoke WebScript in Alfresco remotely using the URL http://192.168.1.2:8080/alfresco/service/sample/folder/Company%20Home and the url will promth me with the authentication window allowing me to entire the username and password. This invocation works completely fine in the Browser..
Followed the steps described in the alfresco : http://wiki.alfresco.com/wiki/Web_Scripts
But when im tring to do the same in android app using webview im facing Authentication Error (HTTP Status 401-Error) and its not promthing me with the authentication window.
If you want to integrate it with an application you can better use the Login Webscript.
So in your app, just make a configure view, which stores the user + pass (encrypted). And then before you do the request login and then with the ticket Authentication call your webscript.
It will then look like this: http://192.168.1.2:8080/alfresco/service/sample/folder/Company%20Home?alf_ticket=<TICKET>
Sometimes that doesn't work, then use http://192.168.1.2:8080/alfresco/service/sample/folder/Company%20Home?ticket=<TICKET> instead.
Good luck!
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....