I have a Django app that access data from Google Tag Manager using its API 
<https://developers.google.com/tag-manager/api/v2/devguide>. It works fine 
locally, but when it is deployed and I try to authenticate, I get this 
message:

UserWarning: Cannot access tagmanager.dat: No such file or directory
Your browser has been opened to visit:

https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%...........If
 your browser is on a different machine then exit and re-run this
application with the command-line parameter
--noauth_local_webserver

And the browser doesn't open a new window for authentication which leads to 
a timeout error.

views.py

import argparseimport sysimport osimport httplib2
from apiclient.discovery import buildfrom oauth2client import clientfrom 
oauth2client import filefrom oauth2client import tools
import pandas as pd
def GetService(api_name, api_version, scope, client_secrets_path):
    parser = argparse.ArgumentParser(
      formatter_class=argparse.RawDescriptionHelpFormatter,
      parents=[tools.argparser])
    flags = parser.parse_args([])

    credentials = run_flow(flow, storage, args)

    flow = client.flow_from_clientsecrets(
    client_secrets_path, scope=scope,
    message=tools.message_if_missing(client_secrets_path))

    storage = file.Storage(api_name + '.dat')
    credentials = storage.get()
    if credentials is None or credentials.invalid:
        credentials = tools.run_flow(flow, storage, flags)
        http = credentials.authorize(http=httplib2.Http())

    service = build(api_name, api_version, 
http=credentials.authorize(http=httplib2.Http()))

    return service

I have also tried to add flags.noauth_local_webserver = True as suggested 
here 
<https://stackoverflow.com/questions/26203571/changing-default-state-of-noauth-local-webserver>,
 
but no luck.

My API configuration is as follows:

Client ID for Web Application

Authorised JavaScript origins URI: https://myapp.appspot.com Authorised 
redirect URIs: https://myapp.appspot.com/accounts/google/login/callback/

I am not sure about the API configuration and the Google docs are 
absolutely useless on this matter.

Other questions on Stackoverflow are either too old or not related to this. 
I have also deployed it to Heroku, but I have the same issue there too

How do I fix this issue?

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/d02933d5-46ce-4c35-8915-aa0af1912d14o%40googlegroups.com.
  • [google-appe... Nicolò Zanellato
    • [google... 'Manpreet Sidhu (Google Cloud Support)' via Google App Engine

Reply via email to