Swift Google日历帐户登出

时间:2016-09-09 19:08:20

标签: ios swift google-calendar-api

我刚开始学习Swift,并实施了Google为我们创建日历的示例代码。但是,我还想知道如何注销帐户以切换到另一个日历,但我似乎无法弄明白。有人可以给我一些指示吗?

提前感谢您的帮助! : - )

1 个答案:

答案 0 :(得分:0)

Google文档的OAuth 2.0版本为revoking a token guide

您可以使用HTTP / REST使用请求:

curl https://accounts.google.com/o/oauth2/revoke?token={token}

如果您不熟悉Swift中的HTTP请求,请使用this threadNSURLConnection中尝试以下指南。

let url = NSURL(string: "https://accounts.google.com/o/oauth2/revoke?token={token}")

let task = NSURLSession.sharedSession().dataTaskWithURL(url!) {(data, response, error) in
    print(NSString(data: data!, encoding: NSUTF8StringEncoding))
}

task.resume()