How to Laravel mobile app api for facebook login - facebook

Hi i'm working on a web with Laravel. On the web, I use socialite to login with Facebook, but I don't know how to do that with api for mobile to connect.
On the web, the flow is the user request to the website, socialite will redirect to facebook to obtain data and redirect back to the redirect url that we register to do authentication.
I don't know if with mobile app is the same?
How can I do it since there is only 1 redirect url and how to detect if the request is from website or from mobile app. Because request from website, ultimately is return view and request from mobilr is return json, right?
Or the mobile side, mobilr developer will do the obtaining data then send it to the website through api to authenticate?
Please help me on this. Thank u. Sorry for my bad English. If anyone does not understand my situation please ask me again.
Thank you all.

If you are building a mobile app, you should use the Facebook Mobile SDK to preform Facebook login instead of doing it the website way. On Facebook, you can have different settings for iOS and Android (and other platforms), so you won't need to worry about knowing which platform the user is using.
When the user authenticates using the mobile app, you can pass the Facebook access_token back to your database via an API.

Related

Facebook Signed_request invalid via mobile app

We have an fb canvas made from .net mvc that works well via desktop but it doesn't work well in mobile app. We send request then if someone on fb mobile tap on request and opens up the web app, the signed_request returned is different than the desktop counterpart. The payload is missing and it seems shorter than the desktop's. I'm trying to read it as "code" and try getting auth token via https://graph.facebook.com/oauth/access_token?client_id=xxxx&code=[code]&redirect_uri=???. The problem with this is I don't know what the redirect_uri supplied or maybe it's not a code.
Can you guys help me with this or there's no other way but once they click request via mobile app we have them relogin in our web app to grab their fbuserid? And if there's another approach in handling mobile app requests.
Mobile Web URL and the signed_request
This is already outdated so maybe there's a solution already.
Thank you
I'll answer my own question. What you can do is add an extra authorization in your login flow when then access your canvas url via facebook mobile app. You send them to
https://graph.facebook.com/oauth/authorize?client_id=
passing the redirect uri and scope then grab the new generated "code" param and grab the aut token via graph api. Then you can access their facebook detail as you would normally. I've read answers like there's no signed request in mobile web and approach it differently without stating what that approach is. Hope someone can be helped by this answer.
Thanks

Facebook authentication for both mobile & web app in Cakephp

Can anyone help me to overcome this hurdle..
My Situation:
I have a webapp (Facebook app) in cakephp, which will b accessed only after Facebook authentication(Its working cool).
& now I have a mobile app & which will work on restapi, I want the same above webapp code to be served as RestApi.
Now I'm able to do authentication for mobile app with facebook, I need to authenticate my webapp which will server as rest api(unless I cannot use the code inside the app)..
Requirement:
I have access_token & user_id with me sent by facebook to my mobile after successful login, & How can i authenticate my web app with these two..??
Can anyone look into this & help me to comeout..!!?
If you want to access Facebook data from inside CakePHP you have to send the access_token & user_id to CakePHP. You probably should narrow down your problem to a specific error or method that fails, here it's not really clear where your problem lies.

How do I login with Facebook credentials on my iPhone application?

I have a web application that authenticates users against Facebook. Once my site redirects them to login with Facebook, FB redirects them back to my site with a valid session cookie. This is a PHPCOOKIE I guess.
I would like to accomplish the same thing from my iPhone application. I have looked at the Facebook iPhone SDK, but that simply lets the iPhone application directly call the graph API.
What I actually want to do is have my backend server call the graph API like it does with the browser.
How do I get the iPhone SDK to pass the session cookie to all requests to my server, the same way the browser does?
This does actually occur- but you're on the iPhone, and the iPhone caches the "cookie" with auth info. It's in NSDefaults. It's also called single-sign-on or SSO. It detects Facebook login and authentication on the native app on the same device, and sets a local (iPhone app default) access token for further graph requests.

connecting to Facebook via custom UI through using the xauth

I am working on a mac application which involves Facebook support so that they can share to Facebook via our app.
For this, I am using Facebook Graph API's which internally uses oAuth protocol to access user resources. In this process, it uses webview to enter users credentials(username and password) which provides the "Access_token".
But my requirement of the application is that it should not use webview to enter user credentials rather it should use other view controller to provide user credentials. So I need to go for xAuth protocol as in twitter uses.
Can anyone help me in this issue? If facebook supports xAuth, please make suggestions.
Facebook doesn't offer "desktop" application authentication support as detailed here: https://developers.facebook.com/docs/authentication/
What you would have to do, is get them to authorize your app on a website, then use the access token for the desktop app and that is if your app is connected to some kind of server.
Otherwise you will have to follow their suggestion of embedding a browser and reading the access token once it is received.

Custom login form to Facebook on an iPhone app

I'm trying to make an application that can connecto to facebook. I've found Facebook Connect for iPhone and I don't like the login form that it has.
Is there any way to make a custom login form? Is there some api functions to call to login an user on Facebook?
Thank you.
I would recommend not going this route. I'd be suspicious of any app that's asking for credentials that's not using the de-facto standard login control. If there is no standard control, then I have to take my chances with whatever the app presents, but in the case of Facebook, the standard control is part of Facebook Connect.
Just use one of the other API's such as the REST API and then create your own UI to capture the login credentials and call the REST API to login.