调用Google API时出现Unity无效授予类型

时间:2019-02-28 19:34:01

标签: c# unity3d google-api jwt

我正在尝试为Google API请求访问令牌。

jwt请求字符串存储在jwtSignature中。如果我在jwtrequest中使用curl或邮递员,则得到正常响应。但我团结一致

    {
  "error": "unsupported_grant_type",
  "error_description": "Invalid grant_type: urn%3aietf%3aparams%3aoauth%3agrant-type%3ajwt-bearer"
}

代码示例:我如何统一拨打电话。我正在使用proyecto26 / RestClient link

WWWForm formData = new WWWForm();
        formData.AddField("grant_type", WWW.EscapeURL("urn:ietf:params:oauth:grant-type:jwt-bearer"));
        formData.AddField("assertion", jwtSignature);
        RequestHelper request = new RequestHelper
        {
            Uri = "https://www.googleapis.com/oauth2/v4/token",
            Method = "POST",
            Headers = new Dictionary<string, string>
            {
                {"charset", "utf-8"},
                {"Content-Type", "application/x-www-form-urlencoded"}
            },
            ContentType = "application/x-www-form-urlencoded",
            FormData = formData,
        };


        RestClient.Post(request, (RequestEcxeption, response) =>
        {
            Debug.Log(RequestEcxeption.ToString());
            Debug.Log(response.Text);
        });

0 个答案:

没有答案