Trouble logging in Instagram using "Login with Facebook" option - ios

I implemented Instagram Login using Basic Display API. Everything works fine if the user enters their Instagram credentials in the web view that comes up on loading https://api.instagram.com/oauth/authorize request. After that I can pull the user's media from the Instagram account. It tells me that everything is implemented properly.
Now, if user choses the "Log in with Facebook" option in the WebView and goes through the Facebook login flow, everything still works fine when I run it on a simulator: after Facebook finishes its login flow with 2 factor authentication I eventually get the redirect callback, parse the code form it and all the rest works as normal.
But the same fails on a physical device. After I call https://api.instagram.com/oauth/access_token to get the token with the obtained code the Instagram app launches momentarily and then opens Safari with this error:
{"message":"Logged-in use not
supported","status":"fail"}
What gives? This is incredibly frustrating, one day was wasted and not sure where to go from here. Any ideas?
UPDATE:
The reason it behaves differently on the device is because it has Instagram app installed and the app gets launched when Facebook calls https://www.instagram.com/accounts/signup/... endpoint to return to the Instagram auth flow (I am watching the requests coming through the WkWebView). Instagram app throws that error above, while on the simulator the end point seems to be serviced fine by the Instagram backend and the flow continues as it should.
So the question is how to get the Instagram app out of the loop.
UPDATE2:
Confirmed - once I deleted the Instagram app from the device it works as expected. Once I install it back it gets launched again during the authentication flow by Facebook and the problem is back. This seems to be a bug in the Instagram app, I have no other explanation.

OK, so after lots of dead ends and obscure rabbit holes I was frantically going down, I have concluded that the real issue is the bug in the Instagram App. As noted in the update to my question the flow started to work fine after I removed the Instagram.
Still not ready to jump to conclusions I tried a few other apps from the Appstore that have Connect to Instagram feature. All of them fail exactly the same way. Specifically if you choose "Continue with Facebook" on the Instagram login WebView you eventually end up launching Instagram app (if it's installed) which in turn throws an error in Safari, and you are stuck.
And you know what the funniest thing is? If you download the Instagram app itself and try to login using the same Facebook flow it will fail as well!
The lesson learned - before you suspect you made a mistake in your implementation check out some other apps with the same feature implemented and maybe you'll discover that you are not alone in your struggle.

The documentation says you should send a POST request to this URL:
Step 2: Exchange the Code For a Token
Once you receive a code, exchange it for a short-lived access token by
sending a POST request to the following endpoint:
POST https://api.instagram.com/oauth/access_token
I didn't get why are you trying to redirect users to this endpoint?

Related

Facebook log in keep redirecting in iOS

I have an Unity application using Facebook SDK for user to link their account. Everything works in Android. But in iOS, the login page keep redirecting to the previous page which asking me to login even I press "Continue".
https://youtu.be/nGs8jiaI24s
I have found that there is a post asking the same question. But the solution does not work for me.
Unity Facebook SDK is keeping on asking me to confirm login every time I login to my game
In my case, FB.IsLoggedIn return false so loginWithReadPermission is still being called and user fall in the loop between login and continue.
Are there any method to solve it, or at least get the error message?

iPhone OAuth login request redirects to App not Browser, doesn't work

My current scenario is:
Running an iPhone on the latest iOS
LinkedIn App is installed and logged in
Web browser is NOT logged into LinkedIn (because I have the app)
Developing a web app with "log in with LinkedIn" functionality
On the iPhone, clicking the "log in with LinkedIn" button redirects me straight the the LinkedIn App, which subsequently does nothing - just shows me my feed. I have verified this same behaviour occurs on a third-party site as well as my own. Note that Android exhibits similar behaviour, though I haven't tested as extensively there.
I've found several workarounds:
If I open the web site in Private Browsing mode clicking the login button asks me if I want to open the App or stay in the browser.
If I long-press and "Open in background tab" the login button it'll open (in the background, of course) instead of redirecting to the app, allowing me to log in.
If I manually type "linkedin.com" into the browser and log in then it seems to work too.
None of these are even vaguely practical for end users, essentially forcing us to remove the option entirely.
I'm fairly sure this is a problem at LinkedIn's end and the solution is either:
Don't redirect to the App for OAuth Authorize requests, or
Make the App correctly handle OAuth Authorize requests.
If I'm incorrect and there's some way we can stop this redirect from the client side I'd be happy to hear, otherwise I hope LinkedIn engineers actually see this...
See the comments in Issues with Linkedin Social connection
LinkedIn already confirmed that it is a problem on their side.

Google Plus not able to redirect to application after sharing in iOS

the issue is in sharing of some thing using google plus in iOS application. the login works fine of google plus in my and google provided demo.
when i implemented it back 2 months it worked fine but suddenly i checked it today it gives error.
1) when i try to share some thing it redirects me to safari as expected. in both case when i am trying to login.
2)but when i press share button it shows sharing dialogue and after that it redirect to new page and error comes like "about:invalid#zClosurez"
3)but when it opens safari for login and i authorise app and it redirect me to my app back perfectly.
4)sharing is working fine the things that user wants to share is shared but it does not redirect back to my app.
https://code.google.com/p/google-plus-platform/issues/detail?id=794&can=8&colspec=ID%20Type%20Status%20Component%20Owner%20Summary%20Stars
click for detailed question
Thanks in advance
This was a bug Google's side with the page that was redirecting the user back - it was fixed in a release this week, so you shouldn't see the issue any longer.

Facebook app redirects users to my app and becomes unusable once SSO is done

I'm updating my app to use the Facebook SDK(3.1) and using [FBSession openActiveSessionWithReadPermissions: allowLoginUI: completionHandler:] for authentication.
Authentication works fine like the following:
Open my app and log in, which uses Facebook SSO.
Redirected to the Facebook app.
Redirected back to my app after authentication, and my app can get
an access token and
necessary information as expected. -
But I have a problem after authentication.
The problem occurs as follows:
Close my app after authentication is done.
Open the Facebook app.
The Facebook app shows a blank view with the cancel button on the navigation bar -
The cancel button does not work.
When I scroll down the blank view, the Facebook app redirects to my app.
Here is one way to reproduce the problem:
Install my app and log in, which uses Facebook SSO.
Log out of my app.
Kill the processes of Facebook app and my app running in the background.
Open my app and log in again.
I tested it with the latest Facebook app and the previous one both on iOS5 and iOS6,
and was able to reproduce the problem with all combinations.
I want to solve this issue, but don't know where the problem is.
Is it a bug in the Facebook SDK or the Facebook app, or any problem in my app?
Thanks.

Not redirecting to Facebook comments in UIWebView after login

I am adding facebook comments to my iPad application using UIWebView and HTML5 code provided by Facebook.
When the user is not logged in, the application shows the comments and button "Login to Facebook to Post a Comment".
Clicking the button takes me through login process. After the login completes the view is redirected with an empty page with "Login complete" message. It is not redirected back to the comments dialog.
Right now I implemented an ugly workaround. Upon receiving webViewDidFinishLoad event, I look at contents of the page and reload it if the page shows this message. Though, it does not seem a clean way to go.
Why doesn't Facebook redirect me back to original comments page?
I suspect the problem you're having is related to this issue: Facebook authentication in a UIWebView does not redirect back to original page on my site asking for auth
Specifically, the standard Facebook web login process launches a new browser window dialog, and dispatches a message back to the opener to indicate login success for the redirect to occur.
Quoting a passage in the linked SO, "UIWebView doesn't support multiple windows so it can't postMessage back to your original page since it's no longer loaded."
I'm also developing an iPad application, and my solution is similar to yours: i drive the user to "https://m.facebook.com", always, to force him to login first, then in "webViewDidFinishLoad" i inspect the returned url and if it matches:
"https://m.facebook.com/login/checkpoint/"
exactly, that is, the url returned upon a successful login, then i call my own method (with reload or anything i want). At this time, the user is authenticated and has a valid FB session, so, redirections are not necessary anymore.
It's definitely not pretty, and may break as soon as FB changes the way it processes the login dialog, but i too cannot find a way to resolve it any better. Even tried using "FB.Event.subscribe('auth.login', function(response) {});" without success, of course, because the code is never reached.
I think a bug is already submitted to FB, but i don't think it's getting the deserved attention...
I ran into same issue as this question, but after reading some Facebook official documentation, I'll be redesigning to use the Facebook native SDK.
All iOS and Android apps must (effective October 2, 2013) use our SDKs
for iOS and Android for requesting permissions.
Though, I also gather that the "or else" is just a "developer notification"?
Posting this in hopes it will save time for someone using the same approach :)

Resources