Important: Starting
May 1, 2024, Apple
requires Privacy Manifests and signatures for iOS applications that use commonly-used SDKs, including GoogleSignIn-iOS. Upgrade to GoogleSignIn-iOS v7.1.0+ before May 1, 2024. Follow
our upgrade guide.
GoogleSignIn Framework Reference
Stay organized with collections
Save and categorize content based on your preferences.
GIDGoogleUser
@interface GIDGoogleUser : NSObject <NSSecureCoding>
This class represents a signed-in user.
-
Declaration
Swift
var userID: String? { get }
Objective-C
@property (nonatomic, readonly, nullable) NSString *userID;
-
The basic profile data for the user.
Declaration
Objective-C
@property (nonatomic, readonly, nullable) GIDProfileData *profile;
-
The OAuth2 scopes granted to the app in an array of NSString
.
Declaration
Swift
var grantedScopes: [String]? { get }
Objective-C
@property (nonatomic, readonly, nullable) NSArray<NSString *> *grantedScopes;
-
The configuration that was used to sign in this user.
Declaration
Objective-C
@property (nonatomic, readonly) GIDConfiguration *_Nonnull configuration;
-
The OAuth2 access token to access Google services.
Declaration
Objective-C
@property (nonatomic, readonly) GIDToken *_Nonnull accessToken;
-
The OAuth2 refresh token to exchange for new access tokens.
Declaration
Swift
var refreshToken: GIDToken { get }
Objective-C
@property (nonatomic, readonly) GIDToken *_Nonnull refreshToken;
-
Declaration
Objective-C
@property (nonatomic, readonly, nullable) GIDToken *idToken;
-
The authorizer for use with GTLRService
, GTMSessionFetcher
, or GTMHTTPFetcher
.
Declaration
Swift
var fetcherAuthorizer: Any { get }
Objective-C
@property (nonatomic, readonly) id _Nonnull fetcherAuthorizer;
-
Refresh the user’s access and ID tokens if they have expired or are about to expire.
Declaration
Swift
func refreshTokensIfNeeded() async throws -> GIDGoogleUser
Objective-C
- (void)refreshTokensIfNeededWithCompletion:
(nonnull void (^)(GIDGoogleUser *_Nullable, NSError *_Nullable))completion;
Parameters
completion
|
A completion block that takes a GIDGoogleUser or an error if the attempt to
refresh tokens was unsuccessful. The block will be called asynchronously on the main queue.
|
-
Starts an interactive consent flow on iOS to add new scopes to the user’s grantedScopes
.
The completion will be called at the end of this process. If successful, a GIDSignInResult
instance will be returned reflecting the new scopes and saved sign-in state will be updated.
Declaration
Swift
func addScopes(_ scopes: [String], presenting presentingViewController: UIViewController) async throws -> GIDSignInResult
Objective-C
- (void)addScopes:(nonnull NSArray<NSString *> *)scopes
presentingViewController:
(nonnull UIViewController *)presentingViewController
completion:(nullable void (^)(GIDSignInResult *_Nullable,
NSError *_Nullable))completion;
Parameters
scopes
|
The scopes to ask the user to consent to.
|
presentingViewController
|
The view controller used to present SFSafariViewContoller on
iOS 9 and 10 and to supply presentationContextProvider for ASWebAuthenticationSession on
iOS 13+.
|
completion
|
The optional block that is called on completion. This block will be called
asynchronously on the main queue.
|
-
Starts an interactive consent flow on macOS to add new scopes to the user’s grantedScopes
.
The completion will be called at the end of this process. If successful, a GIDSignInResult
instance will be returned reflecting the new scopes and saved sign-in state will be updated.
Declaration
Swift
func addScopes(_ scopes: [String], presentingWindow: Any!) async throws -> GIDSignInResult
Objective-C
- (void)addScopes:(nonnull NSArray<NSString *> *)scopes
presentingWindow:(id)presentingWindow
completion:(nullable void (^)(GIDSignInResult *_Nullable,
NSError *_Nullable))completion;
Parameters
scopes
|
An array of scopes to ask the user to consent to.
|
presentingWindow
|
The window used to supply presentationContextProvider for
ASWebAuthenticationSession .
|
completion
|
The optional block that is called on completion. This block will be called
asynchronously on the main queue.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-05-19 UTC.
[null,null,["Last updated 2025-05-19 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eGIDGoogleUser\u003c/code\u003e class represents a signed-in Google user and provides access to their profile information, granted scopes, and tokens.\u003c/p\u003e\n"],["\u003cp\u003eIt offers methods to refresh tokens, add scopes, and authorize requests to Google services.\u003c/p\u003e\n"],["\u003cp\u003eProperties like \u003ccode\u003euserID\u003c/code\u003e, \u003ccode\u003eprofile\u003c/code\u003e, \u003ccode\u003eaccessToken\u003c/code\u003e, and \u003ccode\u003erefreshToken\u003c/code\u003e provide essential user data and authentication credentials.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can use the \u003ccode\u003efetcherAuthorizer\u003c/code\u003e property with \u003ccode\u003eGTLRService\u003c/code\u003e, \u003ccode\u003eGTMSessionFetcher\u003c/code\u003e, or \u003ccode\u003eGTMHTTPFetcher\u003c/code\u003e to authorize requests.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003erefreshTokensIfNeededWithCompletion\u003c/code\u003e and \u003ccode\u003eaddScopes\u003c/code\u003e methods allow for refreshing tokens and adding scopes interactively.\u003c/p\u003e\n"]]],[],null,["# GoogleSignIn Framework Reference\n\nGIDGoogleUser\n=============\n\n @interface GIDGoogleUser : NSObject \u003cNSSecureCoding\u003e\n\nThis class represents a signed-in user.\n- `\n ``\n ``\n `\n\n ### [userID](#/c:objc(cs)GIDGoogleUser(py)userID)\n\n `\n ` \n The Google user ID. \n\n #### Declaration\n\n Swift \n\n var userID: String? { get }\n\n Objective-C \n\n @property (nonatomic, readonly, nullable) NSString *userID;\n\n- `\n ``\n ``\n `\n\n ### [profile](#/c:objc(cs)GIDGoogleUser(py)profile)\n\n `\n ` \n The basic profile data for the user. \n\n #### Declaration\n\n Swift \n\n var profile: ../Classes/GIDProfileData.html? { get }\n\n Objective-C \n\n @property (nonatomic, readonly, nullable) ../Classes/GIDProfileData.html *profile;\n\n- `\n ``\n ``\n `\n\n ### [grantedScopes](#/c:objc(cs)GIDGoogleUser(py)grantedScopes)\n\n `\n ` \n The OAuth2 scopes granted to the app in an array of `NSString`. \n\n #### Declaration\n\n Swift \n\n var grantedScopes: [String]? { get }\n\n Objective-C \n\n @property (nonatomic, readonly, nullable) NSArray\u003cNSString *\u003e *grantedScopes;\n\n- `\n ``\n ``\n `\n\n ### [configuration](#/c:objc(cs)GIDGoogleUser(py)configuration)\n\n `\n ` \n The configuration that was used to sign in this user. \n\n #### Declaration\n\n Swift \n\n var configuration: ../Classes/GIDConfiguration.html { get }\n\n Objective-C \n\n @property (nonatomic, readonly) ../Classes/GIDConfiguration.html *_Nonnull configuration;\n\n- `\n ``\n ``\n `\n\n ### [accessToken](#/c:objc(cs)GIDGoogleUser(py)accessToken)\n\n `\n ` \n The OAuth2 access token to access Google services. \n\n #### Declaration\n\n Swift \n\n var accessToken: ../Classes/GIDToken.html { get }\n\n Objective-C \n\n @property (nonatomic, readonly) ../Classes/GIDToken.html *_Nonnull accessToken;\n\n- `\n ``\n ``\n `\n\n ### [refreshToken](#/c:objc(cs)GIDGoogleUser(py)refreshToken)\n\n `\n ` \n The OAuth2 refresh token to exchange for new access tokens. \n\n #### Declaration\n\n Swift \n\n var refreshToken: ../Classes/GIDToken.html { get }\n\n Objective-C \n\n @property (nonatomic, readonly) ../Classes/GIDToken.html *_Nonnull refreshToken;\n\n- `\n ``\n ``\n `\n\n ### [idToken](#/c:objc(cs)GIDGoogleUser(py)idToken)\n\n `\n ` \n The OpenID Connect ID token that identifies the user.\n\n Send this token to your server to authenticate the user there. For more information on this topic,\n see \u003chttps://developers.google.com/identity/sign-in/ios/backend-auth\u003e. \n\n #### Declaration\n\n Swift \n\n var idToken: ../Classes/GIDToken.html? { get }\n\n Objective-C \n\n @property (nonatomic, readonly, nullable) ../Classes/GIDToken.html *idToken;\n\n- `\n ``\n ``\n `\n\n ### [fetcherAuthorizer](#/c:objc(cs)GIDGoogleUser(py)fetcherAuthorizer)\n\n `\n ` \n The authorizer for use with `GTLRService`, `GTMSessionFetcher`, or `GTMHTTPFetcher`. \n\n #### Declaration\n\n Swift \n\n var fetcherAuthorizer: Any { get }\n\n Objective-C \n\n @property (nonatomic, readonly) id _Nonnull fetcherAuthorizer;\n\n- `\n ``\n ``\n `\n\n ### [-refreshTokensIfNeededWithCompletion:](#/c:objc(cs)GIDGoogleUser(im)refreshTokensIfNeededWithCompletion:)\n\n `\n ` \n Refresh the user's access and ID tokens if they have expired or are about to expire. \n\n #### Declaration\n\n Swift \n\n func refreshTokensIfNeeded() async throws -\u003e GIDGoogleUser\n\n Objective-C \n\n - (void)refreshTokensIfNeededWithCompletion:\n (nonnull void (^)(GIDGoogleUser *_Nullable, NSError *_Nullable))completion;\n\n #### Parameters\n\n |--------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n | ` `*completion*` ` | A completion block that takes a `GIDGoogleUser` or an error if the attempt to refresh tokens was unsuccessful. The block will be called asynchronously on the main queue. |\n\n- `\n ``\n ``\n `\n\n ### [-addScopes:presentingViewController:completion:](#/c:objc(cs)GIDGoogleUser(im)addScopes:presentingViewController:completion:)\n\n `\n ` \n Starts an interactive consent flow on iOS to add new scopes to the user's [grantedScopes](../Classes/GIDGoogleUser.html#/c:objc(cs)GIDGoogleUser(py)grantedScopes).\n\n The completion will be called at the end of this process. If successful, a [GIDSignInResult](../Classes/GIDSignInResult.html)\n instance will be returned reflecting the new scopes and saved sign-in state will be updated. \n\n #### Declaration\n\n Swift \n\n func addScopes(_ scopes: [String], presenting presentingViewController: UIViewController) async throws -\u003e ../Classes/GIDSignInResult.html\n\n Objective-C \n\n - (void)addScopes:(nonnull NSArray\u003cNSString *\u003e *)scopes\n presentingViewController:\n (nonnull UIViewController *)presentingViewController\n completion:(nullable void (^)(../Classes/GIDSignInResult.html *_Nullable,\n NSError *_Nullable))completion;\n\n #### Parameters\n\n |----------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n | ` `*scopes*` ` | The scopes to ask the user to consent to. |\n | ` `*presentingViewController*` ` | The view controller used to present `SFSafariViewContoller` on iOS 9 and 10 and to supply `presentationContextProvider` for `ASWebAuthenticationSession` on iOS 13+. |\n | ` `*completion*` ` | The optional block that is called on completion. This block will be called asynchronously on the main queue. |\n\n- `\n ``\n ``\n `\n\n ### [-addScopes:presentingWindow:completion:](#/c:objc(cs)GIDGoogleUser(im)addScopes:presentingWindow:completion:)\n\n `\n ` \n Starts an interactive consent flow on macOS to add new scopes to the user's [grantedScopes](../Classes/GIDGoogleUser.html#/c:objc(cs)GIDGoogleUser(py)grantedScopes).\n\n The completion will be called at the end of this process. If successful, a [GIDSignInResult](../Classes/GIDSignInResult.html)\n instance will be returned reflecting the new scopes and saved sign-in state will be updated. \n\n #### Declaration\n\n Swift \n\n func addScopes(_ scopes: [String], presentingWindow: Any!) async throws -\u003e ../Classes/GIDSignInResult.html\n\n Objective-C \n\n - (void)addScopes:(nonnull NSArray\u003cNSString *\u003e *)scopes\n presentingWindow:(id)presentingWindow\n completion:(nullable void (^)(../Classes/GIDSignInResult.html *_Nullable,\n NSError *_Nullable))completion;\n\n #### Parameters\n\n |--------------------------|--------------------------------------------------------------------------------------------------------------|\n | ` `*scopes*` ` | An array of scopes to ask the user to consent to. |\n | ` `*presentingWindow*` ` | The window used to supply `presentationContextProvider` for `ASWebAuthenticationSession`. |\n | ` `*completion*` ` | The optional block that is called on completion. This block will be called asynchronously on the main queue. |"]]