In my android app I've got the access token (valid, stored/retrieved into/from sharedPref). My question is if it's possible load a facebook page, say http://m.facebook.com/House into a webview as the current user?
It looks like a dark magic that the SDK can pickup the user session and use it in a webview by just doing a simple CookieSyncManager calls in the authorization process. Any idea how to do it in my own webview? thanks!
You just have to fetch cookie from default browser or from account setup & then you just have to send it to your application's web-view.
Related
i have developed a wordpress website and I used webview for the android app.
now my concern is that whenever a user log in to the app and opens the app after closing the app.I want to keep them logged in !
I was having the same issue and I solved it by enabling a cache for the App. You might be able to do so by adding this to your Webview instance in MainActivity.java:
//enable in-app cache
myWebView.getSettings().setAppCacheEnabled(true);
Hope this works for you too.
This is to be managed by wordpress side, and not in Android.
two ways either save your user login username and password to sharedprefrence and check it everytime or save your user login username and password to sqlite and check if cursor count is 1 then redirect to webview else type username and password.
cache is no good about security also if user when the close app on ios, the cache gonna be delete
I have a Laravel application with login.
It all works fine in a browser, but if I use Android WebView, and try to login, I get an error
Trying to get property of non-object
This is because, when I try and get the user with Auth::user(); it returns null.
I am logging my user in using auth()->login($user) in a function. If I dd($user) at this step, it does get the correct user - but then I redirect into /dashboard which then fires a function, where the first thing it does is to try and get the user.
Its at this point it breaks.
This all works in a browser - also in an android browser. But not in Webview.
Can this have anything to do with the session cookie or something? Is it possible to try and dd() the session cookie to see if it exists?
And if it doesn't, how come this isn't setting in Android Webview?
I have tried using CookieManager.getInstance().setAcceptCookie(true); but this isn't helping, and should also be defined by default.
All help appreciated
Following the Instagram documentation I'm able to authenticate a user and retrieve an access_token easily
But now I want to change of Instagram account which is impossible since the browser automatically call my callback URL because I'm already signed in with an account (there is no login / authorization form again)
To explain what happen here is the authenticate / authorization flow :
Open a browser asking user to log and authorize
User fill up form and submit (this step is skipped when user is already signed in !)
Browser redirect to callback URL
You see step 2 is skipped so we can't login with another user
Does the Instagram have a parameter to force relogin ?
Justin Powell answer is working for log out but I need to be also able to log in just after
and it's quite anoying for Android
But it points me in the right direction : Instagram (like other website) maintains our login with session variable (so with cookies)
So to avoid to be always loged in, we just have to find and remove the correct cookie, here is how to do it with Android :
String cookieString = "sessionid=''";
CookieManager.getInstance().setCookie("instagram.com", cookieString);
With this I set the Instagram sessionid cookie to en empty string so Instagram doesn't recognize me anymore
You could call the Instagram logout url (https://instagram.com/accounts/logout/) in the background before asking for access again. See this question and answers.
I believe the only other option is to leave it up to the user to logout of their Instagram account before loading your access url.
solved the same issue by deleting Access-Token from the app and loading url https://instagram.com/accounts/logout in webview without attaching it to any rootview.
I've added a webview to my Android app so the users can like a specific Facebook page. I've done this using a webview as I've read on here and elsewhere that the Graph API doesn't allow users to like a specific Facebook page.
However, the webview requires the user to login to Facebook the first time that they open the webview, even if they're already logged into the Facebook app (if installed) or touch.facebook.com in the devices browser.
Is there any way around having to login? Can I import any Facebook cookie(s) from the browser into my app in any way, for example?
If I added the Graph API to my app and saved the app's key hash at Facebook, would the user still need to log in once the webview was opened?
Thanks
One approach would be to get an instance of the WebView cookie manager and copy its cookies into your HTTP client cookie store, so that the HTTP client uses the cookies set by the login when subsequently talking to Facebook. Something like this...
CookieManager cookieManager = CookieManager.getInstance();
String cookieString = cookieManager.getCookie("m.facebook.com");
CookieStore mCookieStore = new BasicCookieStore();
mCookieStore.setCookies(cookieString, ".facebook.com", "//");
mCookieStore.sync();
Note that getCookie only gets the cookie's name=value portion, so you will have to add in the domain name and path for the cookie to work in the HTTP client.
Another approach would be to use the Single Sign On (SSO) option on the Facebook SDK authorize function, which will not require a user login if the Facebook app is present and logged in.
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.