Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 281
Move the method addScopes into GIDGoogleUser API#239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
d8e707dba4095f3d0f25dc5a6797e070172f4dd91b32ba6faef5f5998c4d954042912ca9953eff664388cffd65e64b8564File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -17,11 +17,13 @@ | ||
| #import "GoogleSignIn/Sources/GIDGoogleUser_Private.h" | ||
| #import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDConfiguration.h" | ||
| #import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h" | ||
| #import "GoogleSignIn/Sources/GIDAppAuthFetcherAuthorizationWithEMMSupport.h" | ||
| #import "GoogleSignIn/Sources/GIDAuthentication.h" | ||
| #import "GoogleSignIn/Sources/GIDEMMSupport.h" | ||
| #import "GoogleSignIn/Sources/GIDProfileData_Private.h" | ||
| #import "GoogleSignIn/Sources/GIDSignIn_Private.h" | ||
| #import "GoogleSignIn/Sources/GIDSignInPreferences.h" | ||
| #import "GoogleSignIn/Sources/GIDToken_Private.h" | ||
| @@ -181,6 +183,35 @@ - (OIDAuthState *) authState{ | ||
| return ((GTMAppAuthFetcherAuthorization *)self.fetcherAuthorizer).authState; | ||
| } | ||
| - (void)addScopes:(NSArray<NSString *> *)scopes | ||
| #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST | ||
| presentingViewController:(UIViewController *)presentingViewController | ||
| #elif TARGET_OS_OSX || TARGET_OS_MACCATALYST | ||
| presentingWindow:(NSWindow *)presentingWindow | ||
| #endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST | ||
| completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth, | ||
| NSError *_Nullable error))completion { | ||
| if (self != GIDSignIn.sharedInstance.currentUser) { | ||
| NSError *error = [NSError errorWithDomain:kGIDSignInErrorDomain | ||
| code:kGIDSignInErrorCodeMismatchWithCurrentUser | ||
| userInfo:nil]; | ||
| if (completion) { | ||
| dispatch_async(dispatch_get_main_queue(), ^{ | ||
| completion(nil, error); | ||
| }); | ||
| } | ||
| return; | ||
| } | ||
| [GIDSignIn.sharedInstance addScopes:scopes | ||
Alex-4-Git marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. Alex-4-Git marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST | ||
| presentingViewController:presentingViewController | ||
| #elif TARGET_OS_OSX || TARGET_OS_MACCATALYST | ||
| presentingWindow:presentingWindow | ||
| #endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST | ||
| completion:completion]; | ||
| } | ||
| #pragma mark - Private Methods | ||
| #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -14,36 +14,83 @@ | ||
| * limitations under the License. | ||
| */ | ||
| #import <TargetConditionals.h> | ||
| #import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h" | ||
| #if __has_include(<UIKit/UIKit.h>) | ||
| #import <UIKit/UIKit.h> | ||
| #elif __has_include(<AppKit/AppKit.h>) | ||
| #import <AppKit/AppKit.h> | ||
| #endif | ||
| NS_ASSUME_NONNULL_BEGIN | ||
| @class GIDGoogleUser; | ||
| @class GIDSignInInternalOptions; | ||
| // Represents a completion block that takes a `GIDUserAuth` on success or an error if the operation | ||
| // was unsuccessful. | ||
| /// Represents a completion block that takes a `GIDUserAuth` on success or an error if the operation | ||
| /// was unsuccessful. | ||
| typedef void (^GIDUserAuthCompletion)(GIDUserAuth *_Nullable userAuth, NSError *_Nullable error); | ||
| // Private |GIDSignIn| methods that are used internally in this SDK and other Google SDKs. | ||
| @interface GIDSignIn () | ||
| // Redeclare |currentUser| as readwrite for internal use. | ||
| /// Redeclare |currentUser| as readwrite for internal use. | ||
| @property(nonatomic, readwrite, nullable) GIDGoogleUser *currentUser; | ||
| // Private initializer for |GIDSignIn|. | ||
| /// Private initializer for |GIDSignIn|. | ||
Alex-4-Git marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| - (instancetype)initPrivate; | ||
| // Authenticates with extra options. | ||
| /// Authenticates with extra options. | ||
| - (void)signInWithOptions:(GIDSignInInternalOptions *)options; | ||
| // Restores a previously authenticated user from the keychain synchronously without refreshing | ||
| // the access token or making a userinfo request. The currentUser.profile will be nil unless | ||
| // the profile data can be extracted from the ID token. | ||
| // | ||
| // @return NO if there is no user restored from the keychain. | ||
| /// Restores a previously authenticated user from the keychain synchronously without refreshing | ||
| /// the access token or making a userinfo request. | ||
| /// | ||
| /// The currentUser.profile will be nil unless the profile data can be extracted from the ID token. | ||
| /// | ||
| /// @return NO if there is no user restored from the keychain. | ||
| - (BOOL)restorePreviousSignInNoRefresh; | ||
| #if TARGET_OS_IOS || TARGET_OS_MACCATALYST | ||
| /// Starts an interactive consent flow on iOS to add scopes to the current user's grants. | ||
Alex-4-Git marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| /// | ||
| /// The completion will be called at the end of this process. If successful, a `GIDUserAuth` | ||
| /// instance will be returned reflecting the new scopes and saved sign-in state will be updated. | ||
| /// | ||
| /// @param scopes The scopes to ask the user to consent to. | ||
| /// @param presentingViewController The view controller used to present `SFSafariViewContoller` on | ||
| /// iOS 9 and 10 and to supply `presentationContextProvider` for `ASWebAuthenticationSession` on | ||
| /// iOS 13+. | ||
| /// @param completion The block that is called on completion. This block will be called asynchronously | ||
| /// on the main queue. | ||
| - (void)addScopes:(NSArray<NSString *> *)scopes | ||
| presentingViewController:(UIViewController *)presentingViewController | ||
| completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth, | ||
| NSError *_Nullable error))completion | ||
| NS_EXTENSION_UNAVAILABLE("The add scopes flow is not supported in App Extensions."); | ||
| #elif TARGET_OS_OSX | ||
| /// Starts an interactive consent flow on macOS to add scopes to the current user's grants. | ||
| /// | ||
| /// The completion will be called at the end of this process. If successful, a `GIDUserAuth` | ||
| /// instance will be returned reflecting the new scopes and saved sign-in state will be updated. | ||
| /// | ||
| /// @param scopes An array of scopes to ask the user to consent to. | ||
| /// @param presentingWindow The window used to supply `presentationContextProvider` for | ||
| /// `ASWebAuthenticationSession`. | ||
| /// @param completion The block that is called on completion. This block will be called asynchronously | ||
| /// on the main queue. | ||
| - (void)addScopes:(NSArray<NSString *> *)scopes | ||
| presentingWindow:(NSWindow *)presentingWindow | ||
| completion:(nullable void (^)(GIDUserAuth *_Nullable userAuth, | ||
| NSError *_Nullable error))completion; | ||
| #endif | ||
| @end | ||
| NS_ASSUME_NONNULL_END | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.