如何在春季启动中获得facebookoauth访问代码



我正在我的web应用程序中设置oauth2登录(facebook(,引用一些文档。

  • 手动配置OAuth2客户端
    Inhttps://spring.io/guides/tutorials/spring-boot-oauth2/


我写了完整的代码,但它不起作用
下面是我的oauth客户端身份验证流
在步骤4之后,我需要发送一个代码并获得一个访问令牌。但我在任何地方都找不到这方面的代码。

  1. connect-localhost:8080/login/facebook
  2. 重定向-https://www.facebook.com/v3.0/dialog/oauth?redirect_uri=xxx&state=xxx&scope=public_profile+email+user_birthday&response_type=代码&client_id=xxx&ret=登录&logger_id=a10dd655-25bb-1234-baab-feaae59d6e4&ext=1531667216&hash=Aeb1-TBSbxIpZa7c
  3. facebook登录
  4. 重定向-localhost:808/login/facebook?code={某些代码}


我使用poster尝试了以下操作来获取访问代码。但我收到了错误信息;验证码格式无效(错误代码100(

获取-https://graph.facebook.com/oauth/access_token?code=##&redirect_uri=#&client_id=#&client_secret=##

如何获取访问代码
为什么我无法获取access_code

如何获取访问代码?。。

好的。。没有直接的方法从代码中获得access_token,这是redirect - localhost:8008/login/facebook?code={some code}的结果

使用下面的API从代码中获取access_token。

https://graph.facebook.com/v2.11/oauth/access_token?client_id={client_id}&redirect_uri={redirect_uri}&client_secret={client_secret}&code={code}

以上API的结果将返回您的access_token。

最新更新