尝试使用cfoauth标记中的Google帐户登录

时间:2015-12-03 12:25:37

标签: oauth coldfusion coldfusion-11

我正在尝试使用<cfoauth>标记进行登录,但无法执行此操作。它正在显示

  

错误:invalid_request

以下是我的代码。

<cfoauth
type = "google"
clientid = "*****************es7t0r6qc"
secretkey = "**************tSF97WncM5ix9jtvD200"
result = "result"
scope="https://www.googleapis.com/auth/plus.me"
redirecturi = "http://192.168.9.126:8088/bootstrap-blog-template/tpl/cfoauth.cfm"
>

请帮忙。

1 个答案:

答案 0 :(得分:5)

问题似乎与redirecturi有关。您需要提供身份验证后要重定向到的页面的现有且有效的URL。

例如,如果您要测试代码的网页的本地网址是http://localhost:8500/cfbuster/login.cfm,那么redirecturi可以是同一页面,即http://localhost:8500/cfbuster/login.cfm或其他网页http://localhost:8500/cfbuster/doLogin.cfm

除此之外,您要设置的redirecturi应保存在 Google Developers Consele&gt;&gt;中。 API Manager&gt;&gt; Authorized redirect URIs下的凭据屏幕。就我而言,它是http://localhost:8500/cfbuster/test.cfm

enter image description here

如果传递的redirecturi不存在或未在API Authorized redirect URIs屏幕中保存,我们会收到以下错误消息:

enter image description here

注1 redirecturi必须有协议。不能包含URL片段或相对路径。不能是公共IP地址。

注意2 https://www.googleapis.com/auth/plus.login是推荐的登录范围。建议不要将https://www.googleapis.com/auth/plus.me范围用作登录范围,因为对于尚未升级到Google+的用户,它不会返回用户的姓名或电子邮件地址。

相关问题