我收到的错误是请求中缺少参数grant_type
。
将OAuth2用于Web服务器应用程序。
请参阅下面的代码:
var httpClient : HTTPClient = new HTTPClient();
httpClient.setTimeout(3500);
httpClient.setRequestHeader("ContentType", "application/x-www-form-urlencoded");
httpClient.open("POST", "https://accounts.google.com/o/oauth2/token");
var param1:String = "code="+Encoding.toURI(pdict.CurrentHttpParameterMap.code.value.split('.')[0]);
var param2:String = "client_id="+pdict.session.custom.client_id;
var param3:String = "client_secret="+pdict.session.custom.client_secret;
var param4:String = "redirect_uri="+Encoding.toURI(pdict.session.custom.redirect_uri);
var param5:String = "scope=";
var param6:String = "grant_type=authorization_code";
答案 0 :(得分:0)
使用以下语法,即作为Request body的一部分传递变量解决了它。
var client_secret:HTTPRequestPart = new HTTPRequestPart(“client_secret”,pdict.session.custom.client_secret);