@@ -20,7 +20,7 @@ import { AuthProvider, UserCredential } from '../../model/public_types';
20
20
import { _assert } from '../util/assert' ;
21
21
import { AuthErrorCode } from '../errors' ;
22
22
23
- import { OAuthCredential } from '../credentials/oauth' ;
23
+ import { OAuthCredential , OAuthCredentialParams } from '../credentials/oauth' ;
24
24
import { UserCredentialInternal } from '../../model/user' ;
25
25
import { FirebaseError } from '@firebase/util' ;
26
26
import { TaggedWithTokenResponse } from '../../model/id_token' ;
@@ -146,12 +146,19 @@ export class OAuthProvider implements AuthProvider {
146
146
* or the ID token string.
147
147
*/
148
148
credential ( params : OAuthCredentialOptions ) : OAuthCredential {
149
- _assert ( params . idToken && params . accessToken , AuthErrorCode . ARGUMENT_ERROR ) ;
149
+ return this . _credential ( params ) ;
150
+ }
151
+
152
+ /** An internal credential method that accepts more permissive options */
153
+ private _credential (
154
+ params : OAuthCredentialOptions | OAuthCredentialParams
155
+ ) : OAuthCredential {
156
+ _assert ( params . idToken || params . accessToken , AuthErrorCode . ARGUMENT_ERROR ) ;
150
157
// For OAuthCredential, sign in method is same as providerId.
151
158
return OAuthCredential . _fromParams ( {
159
+ ...params ,
152
160
providerId : this . providerId ,
153
- signInMethod : this . providerId ,
154
- ...params
161
+ signInMethod : this . providerId
155
162
} ) ;
156
163
}
157
164
@@ -261,10 +268,11 @@ export class OAuthProvider implements AuthProvider {
261
268
}
262
269
263
270
try {
264
- return new OAuthProvider ( providerId ) . credential ( {
271
+ return new OAuthProvider ( providerId ) . _credential ( {
265
272
idToken : oauthIdToken ,
266
273
accessToken : oauthAccessToken ,
267
- rawNonce : nonce
274
+ rawNonce : nonce ,
275
+ pendingToken
268
276
} ) ;
269
277
} catch ( e ) {
270
278
return null ;
0 commit comments