简体   繁体   中英

Authentication on facebook in c++

I've searched on the internet for days now but I can't seem to find any decent example. My understanding of the oauth2 flow is (please correct me if I'm wrong):

  1. client program asks facebook for a request_token
  2. client program starts a browser, giving it an address containing the client_id and the request_token, and yields to the browser
  3. user logs in/subscribes and accepts the request_token
  4. as soon as focus is returned to the client program, the program sends the request_token it got previously to check it's been authorized; if so, an access token is returned
  5. as long as the access_token is valid, the client program is free to access whatever it needed to

This seems to be confirmed by the oauth2 stub and this page , but I can't find any way to get a request_token in facebook. Even here I couldn't find anything useful. Also getting an access_token or a signed_request containing an access_token would be fine.

The platforms my program should run on include MacOSX, iOS, Win32, Linux. We can currently do http/https communication, and platform-specific code such as ShellExecute() on Win32 is acceptable.

Why don't you check out the official docs instead of looking at the documentation of a provider that implements OAuth 1.0?

As Facebook doesn't implement a flow that directly suits your requirements, the next best flow for you to use would be the Client Side Authentication flow .

It basically works like this:

  1. Open some web browser/view from your application and direct it to Facebook's /dialog/oauth endpoint with the parameters as query string.
  2. Let the user log in and grant your application access rights inside it.
  3. Catch the access_token fragment from the response redirection in the browser view.

How you open a web browser/view from your application and how you catch the redirect highly depens on the operating system/libraries you're using, but should be doable with a little research.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM