Skip to content

Commit 8520637

Browse files
committed
Create class GIDUserAuth (#177)
* Create class GIDUserAuth Add class GIDUserAuth to represent the outcome of a successful signIn or addScopes flow.
1 parent 549213e commit 8520637

File tree

3 files changed

+108
-0
lines changed

3 files changed

+108
-0
lines changed

GoogleSignIn/Sources/GIDUserAuth.m

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2021 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDUserAuth.h"
18+
19+
#import "GoogleSignIn/Sources/GIDUserAuth_Private.h"
20+
#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDGoogleUser.h"
21+
22+
@implementation GIDUserAuth
23+
24+
- (instancetype)initWithGoogleUser:(GIDGoogleUser *)user
25+
serverAuthCode:(nullable NSString *)serverAuthCode {
26+
self = [super init];
27+
if (self) {
28+
_user = user;
29+
_serverAuthCode = serverAuthCode;
30+
}
31+
32+
return self;
33+
}
34+
35+
@end
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2021 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import "GoogleSignIn/Sources/Public/GoogleSignIn/GIDUserAuth.h"
18+
19+
NS_ASSUME_NONNULL_BEGIN
20+
21+
// Private |GIDUserAuth| methods that are used in this SDK.
22+
@interface GIDUserAuth ()
23+
24+
// Private initializer for |GIDUserAuth|.
25+
// @param user The current GIDGoogleUser.
26+
// @param severAuthCode The one-time authorization code for backend to exchange
27+
// access and refresh tokens.
28+
- (instancetype)initWithGoogleUser:(GIDGoogleUser *)user
29+
serverAuthCode:(nullable NSString *)serverAuthCode;
30+
31+
@end
32+
33+
NS_ASSUME_NONNULL_END
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2021 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import <Foundation/Foundation.h>
18+
19+
@class GIDGoogleUser;
20+
21+
NS_ASSUME_NONNULL_BEGIN
22+
23+
/// A helper object that contains the outcome of a successful signIn or addScopes flow.
24+
@interface GIDUserAuth : NSObject
25+
26+
/// The updated `GIDGoogleUser` instance for the user who just completed the flow.
27+
@property(nonatomic, readonly) GIDGoogleUser *user;
28+
29+
/// An OAuth2 authorization code for the home server.
30+
@property(nonatomic, readonly, nullable) NSString *serverAuthCode;
31+
32+
/// Unsupported.
33+
+ (instancetype)new NS_UNAVAILABLE;
34+
35+
/// Unsupported.
36+
- (instancetype)init NS_UNAVAILABLE;
37+
38+
@end
39+
40+
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)