title: PyDrive 2.0 – AuthenticationError: No code found in redirect
body: <p><strong>Set-up</strong></p>
  <p>I'm using PyDrive 2.0 to connect to the Google Drive API.</p>
  <pre><code>def connect_google_drive_api():
      
      import os   
          
      # use Gdrive API to access Google Drive
      os.chdir('/Users/my/fol/ders/access_google_drive')
      from pydrive.auth import GoogleAuth
      from pydrive.drive import GoogleDrive
      
      gauth = GoogleAuth()
      gauth.LocalWebserverAuth() # client_secrets.json need to be in the same directory as the script
      drive = GoogleDrive(gauth)
      
      return drive
  </code></pre>
  <p>The working directory <code>/Users/mypath/access_google_drive</code> contains the <code>client_secrets.json</code>, which looks like,</p>
  <pre><code>{&quot;web&quot;:{&quot;client_id&quot;:&quot;xxx&quot;,&quot;project_id&quot;:&quot;invoice-creation-290413&quot;,&quot;auth_uri&quot;:&quot;https://accounts.google.com/o/oauth2/auth&quot;,&quot;token_uri&quot;:&quot;https://oauth2.googleapis.com/token&quot;,&quot;auth_provider_x509_cert_url&quot;:&quot;https://www.googleapis.com/oauth2/v1/certs&quot;,&quot;client_secret&quot;:&quot;xxx&quot;,&quot;redirect_uris&quot;:[&quot;http://localhost:8080/&quot;],&quot;javascript_origins&quot;:[&quot;http://localhost:8080&quot;]}}
  </code></pre>
  <p>where I replaced the real <code>client_id</code> and <code>client_secret</code> with <code>xxx</code>.</p>
  <hr />
  <p><strong>Issue</strong></p>
  <p>When the browser (Safari 14.0) shows <code>Gdrive api link wants to access your Google Account</code> and I click <code>Allow</code>, the process seems to be stuck.</p>
  <p>After 20 seconds or so, the following error is shown,</p>
  <pre><code>Failed to find &quot;code&quot; in the query parameters of the redirect.
  Try command-line authentication
  Traceback (most recent call last):
  
    File &quot;&lt;ipython-input-36-792f41ab7318&gt;&quot;, line 1, in &lt;module&gt;
      gauth.LocalWebserverAuth()
  
    File &quot;/opt/anaconda3/lib/python3.7/site-packages/pydrive2/auth.py&quot;, line 125, in _decorated
      code = decoratee(self, *args, **kwargs)
  
    File &quot;/opt/anaconda3/lib/python3.7/site-packages/pydrive2/auth.py&quot;, line 273, in LocalWebserverAuth
      raise AuthenticationError(&quot;No code found in redirect&quot;)
  
  AuthenticationError: No code found in redirect
  </code></pre>
  <p>How do I solve this?</p>