GIDGoogleUser
@interface GIDGoogleUser : NSObject <NSSecureCoding>
This class represents a signed-in user.
-
The Google user ID.
Declaration
Swift
var userID: String? { get }
Objective-C
@property (nonatomic, readonly, nullable) NSString *userID;
-
The basic profile data for the user.
Declaration
Swift
var profile: GIDProfileData? { get }
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
Swift
var configuration: GIDConfiguration { get }
Objective-C
@property (nonatomic, readonly) GIDConfiguration *_Nonnull configuration;
-
The OpenID Connect ID token that identifies the user.
Send this token to your server to authenticate the user there. For more information on this topic, see https://developers.google.com/identity/sign-in/ios/backend-auth.
-
The authorizer for use with
GTLRService
,GTMSessionFetcher
, orGTMHTTPFetcher
.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 supplypresentationContextProvider
forASWebAuthenticationSession
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
forASWebAuthenticationSession
.completion
The optional block that is called on completion. This block will be called asynchronously on the main queue.