code: def ServiceAccountCredentialsFromP12File(
          service_account_name, private_key_filename, scopes, user_agent):
      
      private_key_filename = os.path.expanduser(private_key_filename)
      scopes = util.NormalizeScopes(scopes)
      if oauth2client.__version__ > '1.5.2':
          # oauth2client >= 2.0.0
          credentials = (
              service_account.ServiceAccountCredentials.from_p12_keyfile(
                  service_account_name, private_key_filename, scopes=scopes))
          if credentials is not None:
              credentials.user_agent = user_agent
          return credentials
      else:
          # oauth2client < 2.0.0
          with open(private_key_filename, 'rb') as key_file:
              return oauth2client.client.SignedJwtAssertionCredentials(
                  service_account_name, key_file.read(), scopes,
                  user_agent=user_agent)
docs: Create a new credential from the named .p12 keyfile.