Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions GoogleSignIn/Sources/GIDUserAuth.m
Original file line number Diff line number Diff line change
@@ -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
33 changes: 33 additions & 0 deletions GoogleSignIn/Sources/GIDUserAuth_Private.h
Original file line number Diff line number Diff line change
@@ -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
40 changes: 40 additions & 0 deletions GoogleSignIn/Sources/Public/GoogleSignIn/GIDUserAuth.h
Original file line number Diff line number Diff line change
@@ -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 <Foundation/Foundation.h>

@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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth documenting here how this type is supposed to be created?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need to document that. For our clients they only need to read the data inside this class. I will add unsupported here.

Copy link
Collaborator

@mdmathias mdmathias Jul 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think /// Unsupported. adds much. It'd be more helpful to have something like (for this and init below):

Unavailable. See the internally scoped -[GIDUserAuth_Private initWithGoogleUser:serverAuthCode:] to create an instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a public API. There is no benefit if we tell them how to create this instance because we don't want them to do it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. I don't think /// Unsupported. is useful. Feel free to remove.


/// Unsupported.
- (instancetype)init NS_UNAVAILABLE;

@end

NS_ASSUME_NONNULL_END