SafariでのGoogle OAuth
使用に問題があります。cfhttp
私のローカル環境では動作しますが、ホストされた環境では Google OAuth を使用するたびに、以下のリターン コードが返されます。
エラーの詳細:
string 400 Bad Request
ファイルの内容:
string { "error" : "invalid_grant", "error_description" : "Code was already redeemed." }
ヘッダ:
string HTTP/1.1 400 Bad Request Content-Type: application/json Cache-Control: no-cache, no-store, max-age=0, must-revalidate プラグマ: no-cache Expires: Fri, 01 Jan 1990 00:00 :00 GMT 日付: 2014 年 11 月 22 日土曜日 01:38:30 GMT X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-XSS-Protection: 1; mode=block サーバー: GSE 代替プロトコル: 443:quic,p=0.02 Transfer-Encoding: チャンク
<cffunction name="getGoogleToken" access="public" output="false">
<cfargument name="Event" type="any">
<cfargument name="code" type="any">
<cfset var rc = Event.getCollection() />
<cfscript>
var postBody = "code=" & UrlEncodedFormat(arguments.code) & "&";
postBody = postBody & "client_id=" & UrlEncodedFormat(rc.googleclientid) & "&";
postBody = postBody & "client_secret=" & UrlEncodedFormat(rc.googleclientsecret) & "&";
postBody = postBody & "redirect_uri=" & UrlEncodedFormat(rc.googlecallback) & "&";
postBody = postBody & "grant_type=authorization_code";
</cfscript>
<cfhttp url="https://accounts.google.com/o/oauth2/token" method="post" result="result" charset="utf-8">
<cfhttpparam type="header" name="Content-Type" value="application/x-www-form-urlencoded">
<cfhttpparam type="body" value="#postBody#">
</cfhttp>
<cfdump var="#result#" />
<cfabort>
<cfreturn deserializeJSON(result.filecontent.toString()) />
</cffunction>