Issue with importing SignedJwtAssertionCredentials from oauth2client

I’m trying to set up domain-level authentication for the Google Drive API using OAuth2. However, I’m running into an import error related to SignedJwtAssertionCredentials from the oauth2client.client library.

The specific error message that I’m facing is:

ImportError: cannot import name SignedJwtAssertionCredentials

This is the line in my code where the trouble arises:

from oauth2client.client import SignedJwtAssertionCredentials

Although I have installed OpenSSL, the problem persists. The complete traceback reveals that the issue occurs during the import within my Google App Engine environment.

Has anyone experienced this issue? What might be the reason for this import error, and how can I resolve it?

same here! oauth2client is dead - switch to google-auth. way smoother once you make the change. skip the old library entirely.

Had this exact issue with legacy GAE apps. SignedJwtAssertionCredentials got completely removed from oauth2client after version 4.0.0. You could try downgrading oauth2client to 3.0.0, but you’ll probably hit compatibility issues with newer Python versions or other dependencies. Don’t bother fighting with deprecated libraries - I switched to google-auth-oauthlib and google.oauth2.service_account.Credentials.from_service_account_file(). You’ll need to update your token refresh and credential initialization code, but the new library has better error handling and it’s actually maintained. Update your requirements.txt to ditch oauth2client completely and add google-auth instead.

This import error occurs because SignedJwtAssertionCredentials has been deprecated and removed in newer versions of the oauth2client library. I faced the same issue on an old project that had not been updated for years. Given that the oauth2client library has been deprecated since 2017, you are essentially relying on outdated authentication methods. Instead of attempting to fix this old library, I recommend migrating to google-auth, which is currently the standard. You can replace your authentication setup with ServiceAccountCredentials from google.oauth2.service_account or use google.auth.default() for automatic credential detection. This resolved all my import issues and enhanced security features. Although it requires updating your authentication flow, the benefits in terms of maintainability are well worth the effort.

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.