Ios 无法通过调用Swift中的API获取Google联系人

Ios 无法通过调用Swift中的API获取Google联系人,ios,iphone,swift,google-calendar-api,google-contacts-api,Ios,Iphone,Swift,Google Calendar Api,Google Contacts Api,我正在尝试将Google日历事件和Google联系人提取到我的Swift(iOS)应用程序中。 我能够成功登录到谷歌登录,也能够获取日历事件。 但是,在尝试获取Google联系人时,抛出403错误,但是,我已经在Google开发者控制台中为我的项目启用了API private let scopes = ["https://www.googleapis.com/auth/calendar.readonly","https://www.googleapis.com/auth/plus.login",

我正在尝试将Google日历事件和Google联系人提取到我的Swift(iOS)应用程序中。 我能够成功登录到谷歌登录,也能够获取日历事件。 但是,在尝试获取Google联系人时,抛出403错误,但是,我已经在Google开发者控制台中为我的项目启用了API

private let scopes = ["https://www.googleapis.com/auth/calendar.readonly","https://www.googleapis.com/auth/plus.login","https://www.googleapis.com/auth/plus.me","https://www.googleapis.com/auth/contacts.readonly"]


    override func viewDidLoad() {
        super.viewDidLoad()
        GIDSignIn.sharedInstance().clientID = kClientID
        GIDSignIn.sharedInstance().uiDelegate = self
        GIDSignIn.sharedInstance().scopes = scopes 

        // GIDSignIn.sharedInstance().signIn()
        GIDSignIn.sharedInstance().delegate = self
        self.myTableView.isHidden = true
        self.defaultButton.isHidden = false
        dataArray.removeAllObjects()
        self.myTableView.estimatedRowHeight = UITableViewAutomaticDimension
        self.myTableView.rowHeight = UITableViewAutomaticDimension
    }
 func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
        if (error == nil) {

            userEmailID = user.profile.email
        } else {
            print("\(error.localizedDescription)")
        }

        if let error = error {
            showAlert(title: "Authentication Error", message: error.localizedDescription)
            self.service.authorizer = nil
            self.myTableView.isHidden = true
            self.defaultButton.isHidden = false
        } else {
            self.service.authorizer = user.authentication.fetcherAuthorizer()
            fetchEvents()
            getPeopleList()
            self.myTableView.isHidden = false
            self.defaultButton.isHidden = true
            self.myTableView.dataSource = self
            self.myTableView.delegate = self
        }

    }


  func getPeopleList() {
        if let accessToken = GIDSignIn.sharedInstance().currentUser.authentication.accessToken {
            let urlString = ("https://www.googleapis.com/plus/v1/people/me/people/visible?access_token=\(accessToken)")
//            let url = NSURL(string: urlString)
            print(accessToken)
            print(urlString)

            Alamofire.request(urlString).response { response in // method defaults to `.get`
                debugPrint(response.data)
                print(response)
            }
        }

    }
在执行这个程序后,它会显示以下错误

{ Status Code: 403, Headers {
    "Cache-Control" =     (
        "private, max-age=0"
    );
    "Content-Encoding" =     (
        gzip
    );
    "Content-Length" =     (
        136
    );
    "Content-Type" =     (
        "application/json; charset=UTF-8"
    );
    Date =     (
        "Tue, 31 Jul 2018 13:35:51 GMT"
    );
    Expires =     (
        "Tue, 31 Jul 2018 13:35:51 GMT"
    );
    Server =     (
        GSE
    );
    Vary =     (
        Origin,
        "X-Origin"
    );
    "Www-Authenticate" =     (
        "Bearer realm=\"https://accounts.google.com/\", error=insufficient_scope, scope=\"https://www.googleapis.com/auth/plus.login\""
    );
    "alt-svc" =     (
        "quic=\":443\"; ma=2592000; v=\"44,43,39,35\""
    );
    "x-content-type-options" =     (
        nosniff
    );
    "x-frame-options" =     (
        SAMEORIGIN
    );
    "x-xss-protection" =     (
        "1; mode=block"
    );
} }

有人能告诉我哪里做错了吗?

这有帮助吗@马特:不管怎样,这对我没有帮助,谢谢。@AnilkumariOSdeveloper有没有解决这个问题的办法……类似的问题……如果有,请分享。我也有同样的问题,但我有办法。看我的答案,它在起作用