Five Stars

tGoogleAnalyticsInput 401 Unauthorized

Hello Everyone,

 

 

I am creating a job where i need to pull the data from Google Analytics .I had already register the Service account and downloaded the .p12 key File.While running the job i am facing the error

 

tarting job filefetch at 13:05 15/11/2017.

[statistics] connecting to socket on port 3509
[statistics] connected
WARN:Got error:401 Unauthorized
ERROR
top processing because of this error does not allow a retry.
Exception in component tGoogleAnalyticsInput_1
com.google.api.client.auth.oauth2.TokenResponseException: 401 Unauthorized
at com.google.api.client.auth.oauth2.TokenResponseException.from(TokenResponseException.java:105)
at com.google.api.client.auth.oauth2.TokenRequest.executeUnparsed(TokenRequest.java:287)
at com.google.api.client.auth.oauth2.TokenRequest.execute(TokenRequest.java:307)
at com.google.api.client.googleapis.auth.oauth2.GoogleCredential.executeRefreshToken(GoogleCredential.java:384)
at com.google.api.client.auth.oauth2.Credential.refreshToken(Credential.java:489)
at com.google.api.client.auth.oauth2.Credential.intercept(Credential.java:217)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:868)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
[statistics] disconnected
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
at de.jlo.talendcomp.google.analytics.v3.GoogleAnalyticsInput.doExecute(GoogleAnalyticsInput.java:334)
at de.jlo.talendcomp.google.analytics.v3.GoogleAnalyticsInput.executeDataQuery(GoogleAnalyticsInput.java:267)
at de.jlo.talendcomp.google.analytics.v3.GoogleAnalyticsInput.executeQuery(GoogleAnalyticsInput.java:318)
at local_project.filefetch_0_1.filefetch.tGoogleAnalyticsInput_1Process(filefetch.java:629)
at local_project.filefetch_0_1.filefetch.tSetProxy_1Process(filefetch.java:385)
at local_project.filefetch_0_1.filefetch.runJobInTOS(filefetch.java:1026)
at local_project.filefetch_0_1.filefetch.main(filefetch.java:883)
Job filefetch ended at 13:05 15/11/2017. [exit code=1].

 

Can you please let me know the root cause of it. An early response is highly appreciated.

 

Thanks

 

Rohit

3 ACCEPTED SOLUTIONS

Accepted Solutions
Moderator

Re: tGoogleAnalyticsInput 401 Unauthorized

Hello,

From the error message, it seems you have an issue with OAuth 2.0.

Could you please have a look at this article:https://www.rilhia.com/tutorials/using-oauth-20-talend-access-google-apis to see if it is OK with you?

Best regards

Sabrina

 

 

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Five Stars

Re: tGoogleAnalyticsInput 401 Unauthorized

Hello Sabrina,

Thanks for your help.The error got resolved.I have gone through the URL provided and it is very helpful.

Thanks

Rohit
Moderator

Re: tGoogleAnalyticsInput 401 Unauthorized

Hello Rohit ,

Thanks for your feedback. Feel free to post your issue on forum.

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
6 REPLIES
Moderator

Re: tGoogleAnalyticsInput 401 Unauthorized

Hello,

From the error message, it seems you have an issue with OAuth 2.0.

Could you please have a look at this article:https://www.rilhia.com/tutorials/using-oauth-20-talend-access-google-apis to see if it is OK with you?

Best regards

Sabrina

 

 

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Five Stars

Re: tGoogleAnalyticsInput 401 Unauthorized

Hello Sabrina,

Thanks for your help.The error got resolved.I have gone through the URL provided and it is very helpful.

Thanks

Rohit
Moderator

Re: tGoogleAnalyticsInput 401 Unauthorized

Hello Rohit ,

Thanks for your feedback. Feel free to post your issue on forum.

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: tGoogleAnalyticsInput 401 Unauthorized

Hello,

 

I'm also facing the same issue(Got error:401 Unauthorized) with tGoogleAnalyticsInput component.

 

I've followed the link which you have provided but tGoogleAnalyticsInput component has not been used there.

 

More appreciated if you give any suggestions.

 

Thanks,

Naageshwar  

 

 

Four Stars

Re: tGoogleAnalyticsInput 401 Unauthorized

Could anyone help with this issue? As I am also facing it when trying to connect using a service account.

 

The page https://www.rilhia.com/tutorials/using-oauth-20-talend-access-google-apis ,  that is referred to in the solution is not working anymore.

Four Stars

Re: tGoogleAnalyticsInput 401 Unauthorized

I finally managed to tackle it.

Why did not I try this earlier Smiley Sad

 

On console.developers.google.com you need to have 2 account.

The normal user/google account, which you use to login to console.developers.google.com

and a separate service account user. That I had both.

See screenshot : Capture Users

 

Separately when you want to use the service account, the service account itself needs to have access to the view that you wish to read.

And this was what we had wrong .

We only added the normal user/google account with Read privileges to that view, and 'forgot' to add the service account user Smiley Sad

Check via : https://analytics.google.com  

There check (or add) the service account-user (so the <username>@>projectname>-<uniquenr>.iam.gserviceaccount.com) to the view you which to read.

So stupid Smiley Happy