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

App is blocked by Google #580

Closed
OZoneGuy opened this issue Jan 12, 2021 · 17 comments
Closed

App is blocked by Google #580

OZoneGuy opened this issue Jan 12, 2021 · 17 comments
Labels
Milestone

Comments

@OZoneGuy
Copy link

I tried using gcalcli list for the first time and it opened a browser tab asking for verification. After choosing the account I got the following page:

image

Not sure if this is intended or known. I tried this with my personal account and my University's account and I got the same result in both scenarios. I tried using the --noauth_local_webserver option and got the same result after logging in.

Not sure how to solve it, and I couldn't find any similar issues online.

I am tried using both gcalcli and gcalcli-git found on the AUR.

@reeseovine
Copy link

Your best bet is to follow the steps here to get your own API keys: https://github.com/insanum/gcalcli#login-information

Though I have a problem with that where it keeps logging me out and making me re-authenticate every week or so. I may need to get it verified for it to stick.

@OZoneGuy
Copy link
Author

Maybe. I tried creating an API key like the README suggests, but then I get this error page:

image

I haven't used the Google auth API in a long time, so I don't know what has changed or what needs to be done.

@reeseovine
Copy link

In the Cloud Console go to OAuth Consent Screen -> Edit App -> Click continue twice to get to "Test users" and you should be able to add your email.

@aurisnoctis
Copy link

aurisnoctis commented Jan 15, 2021

Steps, loosely following comment #497 (comment)

1. Google Developers Console https://console.developers.google.com

  • create a new project, e.g., gcalcli

2. + Enable APIs and Services"

  • enable Google Calendar API
  • go back to project gcalcli in Developers Console

3. Credentials section in left menu

  • + Create Credentials > OAuth client ID
  • Application type Desktop App
  • name gcalcli
  • The credentials produced here are needed in step 5

4. OAuth consent screen section in left menu

  • I was restricted to choose External users
  • OAuth consent screen
    • App name: e.g., gcalcli
    • User support email: e.g., put your own gmail address
    • App domain: leave all blank
    • Developer contact information: put your own gmail address
  • Scopes: choose all calendar API related stuff plus more if necessary - I did trial and error here ...
  • Test users: again I put my own gmail address here
  • Summary: click "Back to dashboard" at bottom
  • leave Publishing status as Testing so your own gcalcli is not published to the world

5. call gcalcli from command line

  • Use credentials from step 3 in shell command, e.g. for Google agenda view: gcalcli --client_id "your client ID ending in ...apps.googleusercontent.com" --client_secret "your client secret" agenda
  • as my default browser is Firefox I had to copy the URL after Your browser has been opened to visit: (shown in shell after above command) and open it in chromium > follow steps and give permissions to gcalcli
  • in shell, Google calendar agenda is shown 🎉
  • to facilitate the command line call from above to just gcalcli agenda, create a file ~/.gcalclirc with
    --client_id=clientidfromstep3....apps.googleusercontent.com
    --client_secret=clientsecretfromstep3

SO easy! :'D

Update 1: Chromium or Firefox?

With gcalcli v4.0.0a3 from the Linux Mint/Ubuntu repos, the Google website confirmation only works in Chromium. The pip-installed version gcalcli v4.3.0 makes the Google website confirmation process possible in Firefox.

Update 2: --client_id or --client-id?

The above steps worked well with gcalcli v4.0.0a3 from the Linux Mint/Ubuntu repos. However, gcalcli v4.3.0 installed with pip warns:

WARNING: --client_id has been deprecated and will be removed in a future release.
Please use "--client-id", instead.
WARNING: --client_secret has been deprecated and will be removed in a future release.
Please use "--client-secret", instead.gcalcli v4.3.0

If this appears, change the call parameters accordingly in shell command and if applicable in ~/.gcalclirc.

Update 3: upgrade six

When running into error AttributeError: module 'six.moves' has no attribute 'collections_abc' then make sure to upgrade six to the latest version, e.g., by pip3 install --upgrade six.

@aReaSa
Copy link

aReaSa commented Feb 18, 2021

I tried what @aurisnoctis said. However, I couldn't be successful. Is there any other way around to make this work out? Also, I tried with chromium browser.
Thank you.

image

@reeseovine
Copy link

reeseovine commented Feb 18, 2021

I'm using Firefox and it gives me the option to continue with a warning:
gcalcli + Firefox

Look at Update 1 here. Using the pip version is what allows me to use Firefox.

@jcmayoral
Copy link

Thanks @aurisnoctis Really helpful.

@avanavana
Copy link

I had been using this awesome app for about a month, and suddenly today, Google tells me that the app is blocked, and there's nothing I can do to get it authenticated. I had already set it up with my own GCP OAuth credentials, using .gcalclirc and it was working fine. Also, "Allow less secure apps" setting on my Google Account is "ON". I don't understand, I've been developing Google Cloud Platform apps for a few years and I was always given the option to "continue" and "allow" the app, now there is just no option, only a "Blocked" message. Any ideas?

@avanavana
Copy link

I solved this issue using the following resources:

  1. Make sure to turn on your Google account's setting for "Allow less secure apps"
  2. Visit Google's "Display Unlock Captcha" page and click "Continue" to remove the security block.

@DavidTre07
Copy link

Hello all,
what about generating a token from this page ? https://myaccount.google.com/apppasswords
Could it solve this problem ? I think gcalcli is not ready to use such token but it could be a great improvment.

@andersfylling
Copy link

Same issue. I'm trying to read my schedule from my work account, where I can't change any of the above settings.

@aristosv
Copy link

aristosv commented Jun 2, 2021

I tried this guide for creating the client id and client secret and it worked flawlessly. I didn't even have to run "DisplayUnlockCaptcha" nor enable Less Secure Apps.

https://github.com/aristosv/google_auth

@Mellbourn
Copy link

I think the readme of this project should state a bit more clearly that you may have to do a 5+ step guide to authorize this app. Currently, it implies that only OAuth2 will be needed and anything else is optional.

@eastpole
Copy link

eastpole commented May 6, 2022

Just chiming in here that yes, the problem is still blocking simple usage of gcalcli, but on the other hand, the complicated process above does still work when applied with some flexibility. Google keeps changing the dashboards of the relevant API management, so it's hard to feel confident that you are doing the right thing. :) Thank you, @aurisnoctis

@sloanlance
Copy link

sloanlance commented May 8, 2023

Additional information… (At 11:26)

I've been using gcalcli for about a week. I had authorized it to access one of my two Google accounts (my personal account) following the steps in the documentation. It was an awkward process, but I somewhat understand the complexities of working with Google's security.

After using gcalcli for about a week, today I tried to use it to access the calendar belonging to my other Google account (my account in my employer's enterprise). In Google Calendar, long ago I gave each of my Google accounts mutual access to their calendars. I tried to use the gcalcli authorization for my personal account to add an event to my work account. At first, I got the following stack trace…

Traceback (most recent call last):
  File "/Users/lsloan/homebrew/bin/gcalcli", line 33, in <module>
    sys.exit(load_entry_point('gcalcli==4.3.0', 'console_scripts', 'gcalcli')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lsloan/homebrew/Cellar/gcalcli/4.3.0_3/libexec/lib/python3.11/site-packages/gcalcli/cli.py", line 181, in main
    gcal.QuickAddEvent(
  File "/Users/lsloan/homebrew/Cellar/gcalcli/4.3.0_3/libexec/lib/python3.11/site-packages/gcalcli/gcal.py", line 1294, in QuickAddEvent
    new_event = self._retry_with_backoff(
                ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lsloan/homebrew/Cellar/gcalcli/4.3.0_3/libexec/lib/python3.11/site-packages/gcalcli/gcal.py", line 112, in _retry_with_backoff
    return method.execute()
           ^^^^^^^^^^^^^^^^
  File "/Users/lsloan/homebrew/Cellar/gcalcli/4.3.0_3/libexec/lib/python3.11/site-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper
    return wrapped(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lsloan/homebrew/Cellar/gcalcli/4.3.0_3/libexec/lib/python3.11/site-packages/googleapiclient/http.py", line 923, in execute
    resp, content = _retry_request(
                    ^^^^^^^^^^^^^^^
  File "/Users/lsloan/homebrew/Cellar/gcalcli/4.3.0_3/libexec/lib/python3.11/site-packages/googleapiclient/http.py", line 191, in _retry_request
    resp, content = http.request(uri, method, *args, **kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lsloan/homebrew/Cellar/gcalcli/4.3.0_3/libexec/lib/python3.11/site-packages/oauth2client/transport.py", line 186, in new_request
    credentials._refresh(orig_request_method)
  File "/Users/lsloan/homebrew/Cellar/gcalcli/4.3.0_3/libexec/lib/python3.11/site-packages/oauth2client/client.py", line 761, in _refresh
    self._do_refresh_request(http)
  File "/Users/lsloan/homebrew/Cellar/gcalcli/4.3.0_3/libexec/lib/python3.11/site-packages/oauth2client/client.py", line 819, in _do_refresh_request
    raise HttpAccessTokenRefreshError(error_msg, status=resp.status)
oauth2client.client.HttpAccessTokenRefreshError: invalid_grant: Token has been expired or revoked.

Thinking that it might be a temporary problem, I tried again. This time, gcalcli opened the following address in a web browser…

https://accounts.google.com/o/oauth2/v2/auth?client_id=«REDACTED».apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcalendar&access_type=offline&response_type=code

In the Google page that opened, I selected my account name when prompted. The next page showed me the familiar message others have mentioned…

This app is blocked
This app tried to access sensitive info in your Google Account. To keep your account safe, Google blocked this access.

I'm not certain whether this was caused by my token being expired/revoked as mentioned in the first error message or maybe it was triggered by trying to access my work account calendar from my personal account.

Update 1

(Added at 12:09)

I went through all the auth. steps in README again. I created a completely new project in my personal account with new OAuth2 consent screen and client ID. gcalcli goes through the auth and shows me the output of the list command. Not wanting to cause any problems by accessing my work account from my personal account, I tried to add an event to my personal account. I still get the same blocked error message.

I wonder whether I need to add scopes to the Calendar API settings in my project.

Update 2

(Added at 14:10)

I have it working again. I changed a couple of things. First, I added all the GCal scopes to the OAuth consent screen of my new project. That didn't make any difference. I can use the list command, but I get errors with the quick command. Then I had the idea that maybe gcalcli itself is referring to the old project.

So I deleted the gcalcli support files (rm ~/.gcalcli_*). Then I used the list command from the README with the auth settings. That was successful. I could get a calendar listing. Next, when I tried to use quick to create an event in my personal calendar, it worked.

Finally, I tried using my personal account to access the calendar of my work account, to which access has been granted. This time, it worked! 🎉

In conclusion, I'm not sure why access via the first project I set up stopped working. It seems that access between my two accounts doesn't have any effect on the auth. It does seem that gcalcli holds on to past auth data longer than it should.

@jamespo
Copy link
Collaborator

jamespo commented Oct 15, 2023

I've made some modifications in a fork using newer auth methods. Download a creds.json & put it in ~/.config/gcalcli/ - details in the update README.

I'm not providing support, but you can see if it works for you (it works for me).

Be warned this is a quick 30 minute hack, I suggest creating a virtualenv and installing it in there. Also it used my existing ~/.gcalcli_oauth file (not sure why currently) so I moved it to start a new auth flow.

I suggest inspecting the diffs, no guarantees this won't wipe all your appointments!

https://github.com/jamespo/gcalcli

@dbarnett dbarnett added this to the 4.4 milestone Aug 23, 2024
@dbarnett dbarnett added the bug label Aug 24, 2024
@dbarnett
Copy link
Collaborator

Alright, I'm removing the broken client ID from the app entirely in #707 while making the setup process a little friendlier. I'm pretty sure that takes care of all loose ends here, but please reach out with a fresh issue if you're still seeing problems not related to that broken client ID.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests