且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Facebook C#SDK-服务器流身份验证

更新时间:2023-12-03 09:33:16

服务器端身份验证与客户端相同,您使用 RedirectUri 之类的参数将用户重定向到OAuth对话框,然后您 AppId .然后,使用参数 code 将用户重定向到 RedirectUri ,现在您向服务器端发出将代码转换为访问令牌的请求.

Server side authentication is same as client side, you redirect user to OAuth Dialog with parameters like RedirectUri and you AppId. Then user is redirected to RedirectUri with parameter code and now you make server side request to convert code to access token, thats all.

http://developers.facebook.com上阅读用于服务器端身份验证的文档/docs/authentication/server-side/

如何与Facebook C#SDK交换用户访问令牌代码?

How to exchange the code for a User Access Token with Facebook C# SDK?

var fb = new FacebookClient();
dynamic response = fb.Get("oauth/access_token", 
        new
        { 
            client_id = APP_ID,
            redirect_uri = "http://www.example.com/",
            client_secret = SECRET_ID,
            code = CODE
        })
//response.access_token
//response.expires