开发者

Out-of-band OAuth authentication with Facebook

开发者 https://www.devze.com 2023-04-09 16:15 出处:网络
TL;DR version: Can you authenticate with Facebook without having a callback URL for a web application since the web application isn\'t actually running on a server.

TL;DR version:

Can you authenticate with Facebook without having a callback URL for a web application since the web application isn't actually running on a server.

Full explanation:

I'm working on building a connectedTV platform application where the "app" itself is a bunch of HTML/JS/CSS running locally (like File -> Open on your desktop browser) and I'd like to integrate Facebook into this.

The problem is that all of Facebook's OAuth calls for the web require you to have a callback URL to redirect the user to in order to complete authentication. Here's the gotcha -- there is no URL for this application -- it's a locally running webpage on the device.

I know this is what out-of-band authentication was designed for,开发者_如何学编程 but I can't seem to find any documentation on how to use this (or how to do a non-callback OAuth flow) with the Facebook OAuth system.


You're describing desktop authentication or any situation where you are authenticating to FB without a server. The redirect URL you pass to the OAuth dialog is https://www.facebook.com/connect/login_success.html When the browser redirects you can get the access token. You can read all about it in the FB documentation, way at the bottom in the Desktop Apps section (https://developers.facebook.com/docs/authentication/)

Just reread your question and since the application runs inside a browser you will need to open another window to authenticate and get the access token from that.


If you're doing HTML/Javascript, use their Javascript SDK. You can log the guy in simply by using FB.login and getting the access token from the callback from that.


I really don't think this is directly possible. Unless there is something totally undocumented, Facebook has no mechanism to send authentication data except by loading a url. I'm sure it's meant at least partly as a security measure, functioning as sort of a "whitelist" of where auth data will be sent.

The only way I can think of for you to work around it might be to set up a url on a server somewhere that could answer the redirect and store the auth data, and have your client-side code poll that server to get it. Kind of a proxy authentication service, in effect. You would probably have to open a second browser window with the Facebook auth screen in it, but in theory it could work.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号