Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Secrets Error from oauth2client deprecation #62

Open
sugiyama34 opened this issue Apr 6, 2022 · 0 comments
Open

Secrets Error from oauth2client deprecation #62

sugiyama34 opened this issue Apr 6, 2022 · 0 comments

Comments

@sugiyama34
Copy link

Recently, Google deprecated the oauth2client. https://google-auth.readthedocs.io/en/latest/oauth2client-deprecation.html
So, we have error when we try to use d2g.upload and g2d.download with the below Error message.

I think it is possible to reproduce the below error when we run the below code in Google Colab.

(Please replace 'XXXXXX' in gfile.)

from google.colab import auth
auth.authenticate_user()

from google.auth import default
credentials, _ = default()

from df2gspread import df2gspread as d2g
from df2gspread import gspread2df as g2d
import numpy as np
import pandas as pd

df = pd.DataFrame(np.arange(16).reshape(4, 4))

d2g.upload(df=df, gfile='XXXXXXXXXXXXXXXXXXXXXXXXXX', wks_name='test', credentials=credentials, row_names=False)

↓ Error message

Invalid credentials supplied. Will generate from default token.
/usr/local/lib/python3.7/dist-packages/oauth2client/_helpers.py:255: UserWarning: Cannot access /root/.oauth/drive.json: No such file or directory
  warnings.warn(_MISSING_FILE_MESSAGE.format(filename))
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
[/usr/local/lib/python3.7/dist-packages/oauth2client/clientsecrets.py](https://localhost:8080/#) in _loadfile(filename)
    120     try:
--> 121         with open(filename, 'r') as fp:
    122             obj = json.load(fp)

FileNotFoundError: [Errno 2] No such file or directory: '/root/.gdrive_private'

During handling of the above exception, another exception occurred:

InvalidClientSecretsError                 Traceback (most recent call last)
6 frames
[/usr/local/lib/python3.7/dist-packages/oauth2client/clientsecrets.py](https://localhost:8080/#) in _loadfile(filename)
    123     except IOError as exc:
    124         raise InvalidClientSecretsError('Error opening file', exc.filename,
--> 125                                         exc.strerror, exc.errno)
    126     return _validate_clientsecrets(obj)
    127 

InvalidClientSecretsError: ('Error opening file', '/root/.gdrive_private', 'No such file or directory', 2)
@sugiyama34 sugiyama34 changed the title Secrets Error for new Google Authentication Secrets Error from oauth2client deprecation Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant