1616
1717#import " GoogleSignIn/Sources/GIDAuthentication_Private.h"
1818#import " GoogleSignIn/Sources/GIDProfileData_Private.h"
19+ #import " GoogleSignIn/Sources/Public/GoogleSignIn/GIDConfiguration.h"
20+
1921
2022#ifdef SWIFT_PACKAGE
2123@import AppAuth;
@@ -53,30 +55,6 @@ - (nullable NSString *)userID {
5355 return nil ;
5456}
5557
56- - (nullable NSString *)hostedDomain {
57- NSString *idToken = [self idToken ];
58- if (idToken) {
59- OIDIDToken *idTokenDecoded = [[OIDIDToken alloc ] initWithIDTokenString: idToken];
60- if (idTokenDecoded && idTokenDecoded.claims [kHostedDomainIDTokenClaimKey ]) {
61- return [idTokenDecoded.claims[kHostedDomainIDTokenClaimKey ] copy ];
62- }
63- }
64-
65- return nil ;
66- }
67-
68- - (nullable NSString *)serverAuthCode {
69- return [_authState.lastTokenResponse.additionalParameters[@" server_code" ] copy ];
70- }
71-
72- - (nullable NSString *)serverClientID {
73- return [_authState.lastTokenResponse.request.additionalParameters[kAudienceParameter ] copy ];
74- }
75-
76- - (nullable NSString *)openIDRealm {
77- return [_authState.lastTokenResponse.request.additionalParameters[kOpenIDRealmParameter ] copy ];
78- }
79-
8058- (nullable NSArray <NSString *> *)grantedScopes {
8159 NSArray <NSString *> *grantedScopes;
8260 NSString *grantedScopeString = _authState.lastTokenResponse .scope ;
@@ -111,14 +89,41 @@ - (void)updateAuthState:(OIDAuthState *)authState
11189 _authState = authState;
11290 _authentication = [[GIDAuthentication alloc ] initWithAuthState: authState];
11391 _profile = profileData;
92+ _configuration = [[GIDConfiguration alloc ] initWithClientID: [self clientID ]
93+ serverClientID: [self serverClientID ]
94+ hostedDomain: [self hostedDomain ]
95+ openIDRealm: [self openIDRealm ]];
11496}
11597
11698#pragma mark - Helpers
11799
100+ - (NSString *)clientID {
101+ return _authState.lastAuthorizationResponse .request .clientID ;
102+ }
103+
104+ - (nullable NSString *)hostedDomain {
105+ NSString *idToken = [self idToken ];
106+ if (idToken) {
107+ OIDIDToken *idTokenDecoded = [[OIDIDToken alloc ] initWithIDTokenString: idToken];
108+ if (idTokenDecoded && idTokenDecoded.claims [kHostedDomainIDTokenClaimKey ]) {
109+ return [idTokenDecoded.claims[kHostedDomainIDTokenClaimKey ] copy ];
110+ }
111+ }
112+ return nil ;
113+ }
114+
118115- (NSString *)idToken {
119116 return _authState ? _authState.lastTokenResponse .idToken : nil ;
120117}
121118
119+ - (nullable NSString *)serverClientID {
120+ return [_authState.lastTokenResponse.request.additionalParameters[kAudienceParameter ] copy ];
121+ }
122+
123+ - (nullable NSString *)openIDRealm {
124+ return [_authState.lastTokenResponse.request.additionalParameters[kOpenIDRealmParameter ] copy ];
125+ }
126+
122127#pragma mark - NSSecureCoding
123128
124129+ (BOOL )supportsSecureCoding {
@@ -137,6 +142,10 @@ - (nullable instancetype)initWithCoder:(NSCoder *)decoder {
137142 _authState = authentication.authState ;
138143 }
139144 _authentication = [[GIDAuthentication alloc ] initWithAuthState: _authState];
145+ _configuration = [[GIDConfiguration alloc ] initWithClientID: [self clientID ]
146+ serverClientID: [self serverClientID ]
147+ hostedDomain: [self hostedDomain ]
148+ openIDRealm: [self openIDRealm ]];
140149 }
141150 return self;
142151}
0 commit comments