Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/99.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios swift中缺少{error=“invalid”U request“error”描述“=”必需参数:grant“U type”}_Ios_Swift_Alamofire - Fatal编程技术网

Ios swift中缺少{error=“invalid”U request“error”描述“=”必需参数:grant“U type”}

Ios swift中缺少{error=“invalid”U request“error”描述“=”必需参数:grant“U type”},ios,swift,alamofire,Ios,Swift,Alamofire,也可以尝试像这样传递请求参数,但对我来说仍然不起作用。发布请求时,您不能发送带有url的附加参数。 如下所示传递参数 I am trying with this but every time I will get { error = "invalid_request"; "error_description" = "Required parameter is missing: grant_type"; } Request String: let headers =

也可以尝试像这样传递请求参数,但对我来说仍然不起作用。

发布请求时,您不能发送带有url的附加参数。 如下所示传递参数

I am trying with this but every time I will get 

{     error = "invalid_request";     "error_description" = "Required parameter is missing: grant_type"; }

Request String: 

let headers    = [ "Content-Type" : "application/x-www-form-urlencoded"]

let urlString = "https://accounts.google.com/o/oauth2/token?"

Alamofire.request(urlString, method: .post, parameters: ["grant_type":"authorization_code","code":"4/FAOYR1mQo1lN1Gdg9jDnigwZ8RP76NUrqPbYZlMCSP28","client_id":"387376833747-12pbtud9tepr4di0insdhc0d4qpf5e9m.apps.googleusercontent.com","client_secret":"xOacVhLavM9fH8SpOK4I2dRJ","redirect_uri":"https://stackoverflow.com"], encoding: JSONEncoding.default, headers : headers)
            .responseJSON { response in
                print(response)
                print(response.result)
        }

这些错误无效_请求仅在以下情况下发生,因此请与服务器端确认缺少或无效的内容

请求缺少必需的参数,包括不支持的参数 或无效的参数值,重复一个参数,包括多个 凭据,使用多个机制来验证 客户端,或其他格式不正确


您需要按照我所描述的进行传递。我所做的与您所描述的相同,但我必须传递授权\代码值,否则它会给我错误未解析的标识符授权\代码。它是字符串值吗?我认为它是动态值,所以我在那里传递了字符串变量,现在我使用字符串值进行了更改。检查我的更新答案。让我们来看看。所有需要的我放置了参数,我也尝试了很多次同样的事情,但仍然不能得到正确的结果,你能帮我解决它吗?因为这个我必须做其他事情。@IOSdeveloper不能确切地说你是在服务器端代码中工作的吗?是的,我已经在谷歌游乐场中实现了服务器端。
  let headers    = [ "Content-Type" : "application/x-www-form-urlencoded","grant_type" : "authorization_code"" ]

        let urlString = "https://accounts.google.com/o/oauth2/token?"
            Alamofire.request(urlString, method: .post, parameters: ["code":"4/FAOYR1mQo1lN1Gdg9jDnigwZ8RP76NUrqPbYZlMCSP28","client_id":"apps.googleusercontent.com","client_secret":"","redirect_uri":"https://stackoverflow.com"], encoding: JSONEncoding.default, headers : headers)
                .responseJSON { response in
                    print(response)
                    print(response.result)
            }