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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.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 如何从google oauth2获取授权码?_Ios_Swift_Oauth 2.0 - Fatal编程技术网

Ios 如何从google oauth2获取授权码?

Ios 如何从google oauth2获取授权码?,ios,swift,oauth-2.0,Ios,Swift,Oauth 2.0,我得到了一个执行谷歌认证的任务。我的任务就像我应该用谷歌按钮创建一个登录,点击它之后,身份验证过程应该开始,并在下一个视图中显示我的详细信息。我写了这样的代码 let url = URL(string: "https://accounts.google.com/o/oauth2/v2/auth?scope=email%20profile&response_type=code&state=security_token%3D138r5719ru3e1%26url%3Dhttps://

我得到了一个执行谷歌认证的任务。我的任务就像我应该用谷歌按钮创建一个登录,点击它之后,身份验证过程应该开始,并在下一个视图中显示我的详细信息。我写了这样的代码

let url = URL(string: "https://accounts.google.com/o/oauth2/v2/auth?scope=email%20profile&response_type=code&state=security_token%3D138r5719ru3e1%26url%3Dhttps://oauth2.example.com/token&redirect_uri=someuri:/oauth2redirect&client_id=myclient id")!
对于按钮,我编写了如下函数

@IBAction func googleSignIn(_ sender: Any) {
        UIApplication.shared.open(url, options: [:], completionHandler: nil)
 }

我不知道如何获取授权码,以便将其发送回以获取访问令牌。我不应该遵循谷歌提供的任何步骤来集成我的登录,也不应该使用任何POD。有人做过吗?请帮帮我。

通过这个@KushalShrestha我不应该这样做我应该手动完成所有事情,我应该传递客户id并获取授权代码。