1

我正在使用 javascript sdk 进行用户登录

FB.init({appId: applicationId, status: true, cookie: true, xfbml: true, oauth: true});
FB.login(callbackFunction, {scope:permissions});

我在 authResponse 中获得了有效的访问令牌,并且还设置了一个签名的 cookie,它解码了代码。

根据文档访问令牌可以用

https://graph.facebook.com/oauth/access_token?client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&client_secret=YOUR_APP_SECRET&code=THE_CODE_FROM_ABOVE

当我使用代码尝试此操作时,我收到错误验证验证码错误。100

作为redirect_uri,我尝试了设置为App Domain 和siteURL 的uri。这些给出了那个错误。与其他 uri 我得到Invalid redirect_uri: Given URL is not allowed by the application configuration. 191

我在这里是否以不好的方式混合了客户端流和服务器端流,或者我应该在使用时使用一些 redirect_uri 参数,FB.init或者FB.login在通过代码获取访问令牌时使用该确切的 uri?

4

1 回答 1

0

FB.login(callbackFunction, {scope:permissions}); 回调函数被发送一个对象

       authResponse: {          /* Information about the current session */
          userID: ""          /* String representing the current user's ID */
          signedRequest: "",  /* String with the current signedRequest */
          expiresIn: "",      /* UNIX time when the session expires */
          accessToken: "",    /* Access token of the user */
       }

这里是不需要通过调用另一个 URL 来转换的用户访问令牌。它准备好了大约一个小时,然后你需要买一个新的。

于 2012-02-23T14:24:45.897 回答