insanum / gcalcli

Google Calendar Command Line Interface
MIT License
3.33k stars 314 forks source link

error invalid client - unauthorized #814

Closed danixland closed 2 weeks ago

danixland commented 2 weeks ago

Hello, I've installed gcalcli 4.5.0 through pip, I've created the google app and I've launched: gcalcli --client-id "myclientid" init

After visiting the page both on firefox and on chromium I receive the same python error:

  File "/home/danix/.local/bin/gcalcli", line 8, in <module>                                                                                
    sys.exit(main())                                                                                                                        
             ^^^^^^                                                                                                                         
  File "/home/danix/.local/lib/python3.11/site-packages/gcalcli/cli.py", line 246, in main                                                  
    gcal.SetupAuth()                                                                                                                        
  File "/home/danix/.local/lib/python3.11/site-packages/gcalcli/gcal.py", line 279, in SetupAuth                                            
    self.credentials = auth.authenticate(                                                                                                   
                       ^^^^^^^^^^^^^^^^^^                                                                                                   
  File "/home/danix/.local/lib/python3.11/site-packages/gcalcli/auth.py", line 52, in authenticate                                          
    credentials = flow.run_local_server(open_browser=False, port=port)                                                                      
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                      
  File "/home/danix/.local/lib/python3.11/site-packages/google_auth_oauthlib/flow.py", line 455, in run_local_server                        
    self.fetch_token(                                                                                                                       
  File "/home/danix/.local/lib/python3.11/site-packages/google_auth_oauthlib/flow.py", line 285, in fetch_token                             
    return self.oauth2session.fetch_token(self.client_config["token_uri"], **kwargs)                                                        
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                        
  File "/home/danix/.local/lib/python3.11/site-packages/requests_oauthlib/oauth2_session.py", line 406, in fetch_token                      
    self._client.parse_request_body_response(r.text, scope=self.scope)                                                                      
  File "/home/danix/.local/lib/python3.11/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 427, in parse_request_body_response  
    self.token = parse_token_response(body, scope=scope)                                                                                    
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                    
  File "/home/danix/.local/lib/python3.11/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 441, in parse_token_response           
    validate_token_parameters(params)                                                                                                       
  File "/home/danix/.local/lib/python3.11/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 448, in validate_token_parameters      
    raise_from_error(params.get('error'), params)                                                                                           
  File "/home/danix/.local/lib/python3.11/site-packages/oauthlib/oauth2/rfc6749/errors.py", line 399, in raise_from_error                   
    raise cls(**kwargs)                                                                                                                     
oauthlib.oauth2.rfc6749.errors.InvalidClientError: (invalid_client) Unauthorized

I've completed the procedure in the browser but after returning to the console I see this error and I have no idea where to go from here.

Any help would be appreciated. Thanks

dbarnett commented 2 weeks ago

Well, invalid client suggests something is wrong in the client project you're using from Google Cloud Console (or maybe with just the ID you supplied for it?), but unfortunately if the auth library doesn't work it doesn't surface a lot of clues about what went wrong beyond what you're seeing there.

There were some errors we were discussing in #628 but I think those had a different error message.

danixland commented 2 weeks ago

I've deleted the previous app and created a new one with new oauth credentials, I've done the whole procedure on chromium and now it worked.

I have no idea what went wrong yesterday but I've followed the same exact procedure. Anyway, this issue can be closed now Thanks for your help

dbarnett commented 2 weeks ago

Great! Feel free to report any further weirdness you do see.