diff --git a/googleapis_auth/lib/src/auth_functions.dart b/googleapis_auth/lib/src/auth_functions.dart index bf575ceac..244a9b3b1 100644 --- a/googleapis_auth/lib/src/auth_functions.dart +++ b/googleapis_auth/lib/src/auth_functions.dart @@ -108,11 +108,6 @@ Future refreshCredentials( Client client, { AuthEndpoints authEndpoints = const GoogleAuthEndpoints(), }) async { - final secret = clientId.secret; - if (secret == null) { - throw ArgumentError('clientId.secret cannot be null.'); - } - final refreshToken = credentials.refreshToken; if (refreshToken == null) { throw ArgumentError('clientId.refreshToken cannot be null.'); @@ -122,7 +117,9 @@ Future refreshCredentials( final jsonMap = await client.oauthTokenRequest( { 'client_id': clientId.identifier, - 'client_secret': secret, + // Not all providers require a client secret, + // e.g. https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-auth-code-flow#refresh-the-access-token + if (clientId.secret != null) 'client_secret': clientId.secret!, 'refresh_token': refreshToken, 'grant_type': 'refresh_token', },