I have set up my project to sign in to a user's Google account using the Google Sign In framework. It works fine, but I want to use the access token that I get from the sign in to access the user's Google Drive. I am programming for iOS and have already set up the Drive SDK in my project. I feel like there should be a simple way of doing this. Thank You!
Recently experienced the same problem myself when attempting to use the Calendar API.
You can access the access token (and therefore use it in your URL Requests) like so:
if (GIDSignIn.sharedInstance().currentUser != nil) {
let accessToken = GIDSignIn.sharedInstance().currentUser.authentication.accessToken
// Use accessToken in your URL Requests Header
}
Make sure to only call this method after the user has signed in, the check for current user will prevent a crash from implicitly unwrapping a nil value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With