Hey, I’ve been using the tap-google-analytics but ...
# troubleshooting
p
Hey, I’ve been using the tap-google-analytics but somehow I can’t seem to get working it with
client_secrets
param? anyone has faced this before?
the stringified json is in the environment as
TAP_GOOGLE_ANALYTICS_CLIENT_SECRETS
tried to get in the code but I can’t seem to find the exact issue,
seems like all are pointing to how the key is serialized: I am doing the following to serialized the client_secret.json:
Copy code
with open("client_secrets.json") as fl:
    ...:     data  = fl.read()
    ...:     data = json.dumps(json.loads(data))
If I edit the above string to only have single
\
then it fails with
Expecting value: line 1 column 1 (char 0)
cc @hitesh
I think the current setup fails to get the tap working from env
I found that when python tries to read from environment via os it puts ‘/’ before ‘/n’ making it ‘//n’. This either requires a fix at this line: https://github.com/googleapis/oauth2client/blob/master/oauth2client/service_account.py#L185 but it’s now public arrchive
okay if I do it directly via ipython I’m able to pass the error that I get when I pass the environment var using meltano. if I just put a single
\
then Meltano gives me the parsing error, while I’m able to parse the string using json and using oauth2client libraby in ipython. Can someone help me understand how does env vars are parsed in meltano and why it is supposedly trying to double parse ?
was anyone able to run this tap via env?
p
@prakhar_srivastava I have an environment variable in my .env that works for this and it looks like
TAP_GOOGLE_ANALYTICS_CLIENT_SECRETS="{\"type\": \"service_account\",\"project_id\": \"my-project-id\",\"private_key_id\": \"foo\",\"private_key\": \"-----BEGIN PRIVATE KEY-----\\nbar...
I guess single backslash for the quotes and double for the new line characters
It looks like you might have tried that already and your link says escape characters are potentially OS based. I've done this on my Mac and using the meltano docker image, if that helps at all
p
hey @pat_nadolny thanks for the reply, I’m using mac as well with meltano on my machine, not using docker.
how did you serialize the json? I think this is how JS serde happens
p
It was a while ago so I dont really remember but I can try to replicate mine and figure it out
p
yes please if you can, would be very helpful
message has been deleted
secret looks like:
export TAP_GOOGLE_ANALYTICS_CLIENT_SECRETS="{\"type\": \"service_account\",\n    \"project_id\"
p
hmm maybe its that new line after service account 🤔 I dont see that in mine, again not sure how I serialized mine
p
I reckon it is still breaking
its that new line after service account 🤔
Yep I saw and removed these extra
\n
and I come back to the same error. What’s the meltano version/docker image you’re using — I’ll give that a shot
also try running
meltano config tap-google-analytics
and make sure your config prints out as expected
Mine looks like:
Copy code
{
    "view_id": "xyz",
    "client_secrets": {
        "type": "service_account",
        "project_id": "foo",
        "private_key_id": "bar",
        "private_key": "-----BEGIN PRIVATE KEY-----\nABC\nDEF\n-----END PRIVATE KEY-----\n",
Looks like I'm using 2.10.0 thats installed in my docker image
p
I used your files to build the image and used .env file, still couldn’t run it 😕 this works with client_secret file but not with env
a
Did you inspect the output of
meltano config tap-google-analytics
?
p
message has been deleted
p
Oh you should try removing key_file_location it’s probably taking precedence over the client secret in your config