문제 설명
로컬 HTML 파일에서 oAuth 흐름을 처리합니까? (Handling an oAuth flow from local HTML files?)
JSON API를 사용하는 로컬 HTML + Javascript 파일이 있습니다. Facebook을 통해 사용자를 인증하고 싶지만 이것이 가능한지 확실하지 않습니다. 경험이 있는 사람이 있습니까? file:// 컨텍스트에서 서비스를 제공할 때 리디렉션(Facebook에서 다시)이 어떻게 관리되는지 잘 모르겠습니다.
참조 솔루션
방법 1:
Just do it! :)
And you'll see.
PS Maybe you should encode some characters like ":", "/" etc
방법 2:
Unfortunately, it won't work from a file:// context for a couple reasons:
In most modern browsers, Javascript cookies won't work with the file:// protocol, which is how you would probably authenticate your users. This can be solved by hosting the page using http:// from localhost.
In order to log a client in using facebook, you need a registered facebook app, and to register your facebook app, you have to give facebook a static domain where your app will be hosted. This is to ensure that requests for your app come from your domain and not from an attacker residing at a different domain.
Last but not least, because your users have to authorize your app on facebook.com, you also need to specify a redirect url after their successful login, which would be very challenging to circumvent.
방법 3:
it won't work under file:// context. as James said, authentication through facebook requires your have a hosted web page and also register your site as facebook app; and also , facebook will need to redirect the browser to a so called "callback" url, which must be a http:// web page.
you can choose to host your webpage in a local web server instead
(by Michael F、Lex、James M. Lay、fuyi)