Search code examples
iosswiftgidsignin

Google Sign In fetch extra data


Can I fetch extra data from Google using GIDSignIn over google+ sign in? Currently I am getting the following data:

            let userId = user.userID                  
            let idToken = user.authentication.idToken 
            let fullName = user.profile.name
            let givenName = user.profile.givenName
            let familyName = user.profile.familyName
            let email = user.profile.email
            if (user.profile.hasImage) {
                let imageUrl = user.profile.imageURLWithDimension(75)
                print (imageUrl)
            }

But i need more info from google account. Can't find any info about it in google tutorial.


Solution

  • I have just checked the GIDGoogleUser and those are the only information you can fetch for the user profile(GIDProfileData)!

    func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!,
            withError error: NSError!)
    

    The signIn method gives you the reference to the GIDGoogleUser with gives you the information you already know how to fetch, and it also gives you the Google user ID, the accessible scopes, host domains and authentication methods. You can check all of this at the Google Developers Sign In for iOS.