Google通讯录OAUTH2

时间:2017-04-15 16:55:30

标签: ios swift

我正在尝试获取Google通讯录,但当用户登录选项显示时,会显示targetHeight的权限。但没有联系人的权限。此外,当用户成功登录时,它会将我重定向到谷歌搜索页面。

Html.textarea 
    [ style model
    , onClick HeightChange
    , whenBackspacePressed_ReceiveScrollHeight HeightChange
    , onInput TextChange, .. etc

网址计划

enter image description here

1 个答案:

答案 0 :(得分:1)

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
    GIDSignIn.sharedInstance().delegate = self
    GIDSignIn.sharedInstance().uiDelegate = self
    GIDSignIn.sharedInstance().clientID = ""

GIDSignIn.sharedInstance().scopes.append("https://www.googleapis.com/auth/plus.login")
GIDSignIn.sharedInstance().scopes.append("https://www.googleapis.com/auth/plus.me")
GIDSignIn.sharedInstance().scopes.append("https://www.googleapis.com/auth/contacts.readonly")


GIDSignIn.sharedInstance().signInSilently()

}

您需要添加这些范围,然后尝试知道您只是要求获取信息的权限

 // App Delegate Handle Url Scheme
 open func application(_ application: UIApplication, open url: URL, 
 sourceApplication: String?, annotation: Any) -> Bool {
    var returnScheme: Bool!
    if url.scheme == "dropbox"{
        returnScheme = true
    }else if url.scheme == "Goolge URL SCHEME Which you have added in plist file"{
        returnScheme = GIDSignIn.sharedInstance().handle(url,
                                                         sourceApplication: sourceApplication,
                                                         annotation: annotation)
    }
    return returnScheme
}