diff --git a/GoogleSignIn/Sources/GIDUserAuth.m b/GoogleSignIn/Sources/GIDUserAuth.m new file mode 100644 index 00000000..90dfa289 --- /dev/null +++ b/GoogleSignIn/Sources/GIDUserAuth.m @@ -0,0 +1,35 @@ +/* + * Copyright 2021 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDUserAuth.h" + +#import "GoogleSignIn/Sources/GIDUserAuth_Private.h" +#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDGoogleUser.h" + +@implementation GIDUserAuth + +- (instancetype)initWithGoogleUser:(GIDGoogleUser *)user + serverAuthCode:(nullable NSString *)serverAuthCode { + self = [super init]; + if (self) { + _user = user; + _serverAuthCode = serverAuthCode; + } + + return self; +} + +@end diff --git a/GoogleSignIn/Sources/GIDUserAuth_Private.h b/GoogleSignIn/Sources/GIDUserAuth_Private.h new file mode 100644 index 00000000..2f80b9ee --- /dev/null +++ b/GoogleSignIn/Sources/GIDUserAuth_Private.h @@ -0,0 +1,33 @@ +/* + * Copyright 2021 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDUserAuth.h" + +NS_ASSUME_NONNULL_BEGIN + +// Private |GIDUserAuth| methods that are used in this SDK. +@interface GIDUserAuth () + +// Private initializer for |GIDUserAuth|. +// @param user The current GIDGoogleUser. +// @param severAuthCode The one-time authorization code for backend to exchange +// access and refresh tokens. +- (instancetype)initWithGoogleUser:(GIDGoogleUser *)user + serverAuthCode:(nullable NSString *)serverAuthCode; + +@end + +NS_ASSUME_NONNULL_END diff --git a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDUserAuth.h b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDUserAuth.h new file mode 100644 index 00000000..0d91b8cd --- /dev/null +++ b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDUserAuth.h @@ -0,0 +1,40 @@ +/* +* Copyright 2021 Google LLC +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#import + +@class GIDGoogleUser; + +NS_ASSUME_NONNULL_BEGIN + +/// A helper object that contains the outcome of a successful signIn or addScopes flow. +@interface GIDUserAuth : NSObject + +/// The updated `GIDGoogleUser` instance for the user who just completed the flow. +@property(nonatomic, readonly) GIDGoogleUser *user; + +/// An OAuth2 authorization code for the home server. +@property(nonatomic, readonly, nullable) NSString *serverAuthCode; + +/// Unsupported. ++ (instancetype)new NS_UNAVAILABLE; + +/// Unsupported. +- (instancetype)init NS_UNAVAILABLE; + +@end + +NS_ASSUME_NONNULL_END