Today's Menu  Portugal
journal and plan nutrition
GIDAuthentication.h
Go to the documentation of this file.
1 /*
2  * GIDAuthentication.h
3  * Google Sign-In iOS SDK
4  *
5  * Copyright 2014 Google Inc.
6  *
7  * Use of this SDK is subject to the Google APIs Terms of Service:
8  * https://developers.google.com/terms/
9  */
10 
11 #import <Foundation/Foundation.h>
12 
13 @protocol GTMFetcherAuthorizationProtocol;
14 @class GIDAuthentication;
15 
16 // @relates GIDAuthentication
17 //
18 // The callback block that takes a GIDAuthentication, or an error if attempt to refresh was
19 // unsuccessful.
20 typedef void (^GIDAuthenticationHandler)(GIDAuthentication *authentication, NSError *error);
21 
22 // @relates GIDAuthentication
23 //
24 // The callback block that takes an access token, or an error if attempt to refresh was
25 // unsuccessful.
26 typedef void (^GIDAccessTokenHandler)(NSString *accessToken, NSError *error);
27 
28 // This class represents the OAuth 2.0 entities needed for sign-in.
29 @interface GIDAuthentication : NSObject <NSCoding>
30 
31 // The client ID associated with the authentication.
32 @property(nonatomic, readonly) NSString *clientID;
33 
34 // The OAuth2 access token to access Google services.
35 @property(nonatomic, readonly) NSString *accessToken;
36 
37 // The estimated expiration date of the access token.
38 @property(nonatomic, readonly) NSDate *accessTokenExpirationDate;
39 
40 // The OAuth2 refresh token to exchange for new access tokens.
41 @property(nonatomic, readonly) NSString *refreshToken;
42 
43 // An OpenID Connect ID token that identifies the user. Send this token to your server to
44 // authenticate the user there. For more information on this topic, see
45 // https://developers.google.com/identity/sign-in/ios/backend-auth
46 @property(nonatomic, readonly) NSString *idToken;
47 
48 // The estimated expiration date of the ID token.
49 @property(nonatomic, readonly) NSDate *idTokenExpirationDate;
50 
51 // Gets a new authorizer for GTLService, GTMSessionFetcher, or GTMHTTPFetcher.
52 - (id<GTMFetcherAuthorizationProtocol>)fetcherAuthorizer;
53 
54 // Get a valid access token and a valid ID token, refreshing them first if they have expired or are
55 // about to expire.
56 - (void)getTokensWithHandler:(GIDAuthenticationHandler)handler;
57 
58 // Refreshes the access token and the ID token using the refresh token.
59 - (void)refreshTokensWithHandler:(GIDAuthenticationHandler)handler;
60 
61 // Gets the access token, which may be a new one from the refresh token if the original has already
62 // expired or is about to expire. Deprecated: use |getTokensWithHandler:| to get access tokens
63 // instead.
64 - (void)getAccessTokenWithHandler:(GIDAccessTokenHandler)handler
65  DEPRECATED_MSG_ATTRIBUTE("Use |getTokensWithHandler:| instead.");
66 
67 // Refreshes the access token with the refresh token. Deprecated: Use |refreshTokensWithHandler:|
68 // to refresh access tokens instead.
69 - (void)refreshAccessTokenWithHandler:(GIDAccessTokenHandler)handler
70  DEPRECATED_MSG_ATTRIBUTE("Use |refreshTokensWithHandler:| instead.");
71 
72 @end
void(^ GIDAuthenticationHandler)(GIDAuthentication *authentication, NSError *error)
NSDate * idTokenExpirationDate
id< GTMFetcherAuthorizationProtocol > fetcherAuthorizer()
NSDate * accessTokenExpirationDate
void(^ GIDAccessTokenHandler)(NSString *accessToken, NSError *error)