Closed GoogleCodeExporter closed 8 years ago
Take a look at your authorization code. Feel free to ask for help on
stackoverflow with the tags google-analytics and google-analytics-api.
Is there a reason you are not using Java Client libraries, they truly make
authentication much easier.
https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/s
ervice-java
Original comment by mcoh...@google.com
on 6 Nov 2015 at 12:08
Due to security reason our firewall blocks the URL googleapi.com , due to this
reason we are using proxy urls, which is not working in case google client
library and failing with SSL exception/unknown host exception every time.
So API is the only option available with us and there is no problem
authorization code as the same code works while downloading a report.
The only difference is GET and POST. while downloading the report we are using
GET and while generating the report POST being used. If it is working for you,
can you please share sample code fro POST request while generating the report.
(I already have attached my post request, I might be doing some mistake while
preparing the data, Please validate the same)
It will be of great help for us.
Thanks
Prasant
Original comment by prasantv...@gmail.com
on 6 Nov 2015 at 1:27
I have never seen the token passed in as a url parameter call bearer only ever
access_token=ya29.....
you might try
conn.setRequestProperty ("Authorization", "Bearer ya29......");
I would also play around with OAuth2 playground: goo.gl/t4QLLJ to get a sense
of how the auth structure is expected.
An invalid token could mean simply that the token has expired.
https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=
Original comment by mcoh...@google.com
on 6 Nov 2015 at 5:40
Thanks a lot for your valuable solution, It worked like a charm. I have tried
my request in the OUAUTH playground and rectified my request accordingly.
The report got generated successfully, However I am facing another issue while
downloading the same report, Kindly advise on the below issue.
We are using service id + access token to generate the report and the report is
getting saved in cloud storage. Using the same token I am able to List all the
properties of the report including title,bucket id and the name of the csv file.
Even if I am using the same token, It fails with the following exception
Server returned HTTP response code: 403 for URL:
https://www.googleapis.com/storage/v1/b/6745420671024221519-opus-test/o/Prasant_
Report_Final_New_13th18.csv
The GET request is attached here.
Note: The same code is working fine if the report got generated using my userid
instead of service id with help of manual work around. (The screen shots
attached).
which is not possible to do this manual work around in case of service id. And
also our requirement is to automate it instead of any kind of manual
interaction.
Kindly help us to resolve this issue.
Regards
Prasant
Regards
Original comment by prasantv...@gmail.com
on 7 Nov 2015 at 6:06
Attachments:
I think it is a user permissions issue. With the service account you are able
to create unsampled reports and list them with the Google Analytics API. But
you are unable to download the report with the same service account because
when you initially configured the unsampled report you have it sent to a
particular user account.
You could be getting this error for two reasons.
1. You have granted the service account access to your Google Analytics Account
but not your Cloud Storage Account.
2. You have generated the authorization token with the correct API scopes for
the Google Analytics API but not for the Cloud Storage API scopes.
I would strongly encourage you to include the FULL JSON response for your
errors as wells any code you are using the authorize the API at stack overflow
under the appropriate tags:
http://stackoverflow.com/questions/tagged/google-analytics
http://stackoverflow.com/questions/tagged/google-analytics-api
http://stackoverflow.com/questions/tagged/google-cloud-storage
Original comment by mcoh...@google.com
on 9 Nov 2015 at 3:02
Thanks a lot for your response, You are right, I was not using proper scope
for cloud. I got it resolved yesterday.
All are working fine now.
Original comment by prasantv...@gmail.com
on 9 Nov 2015 at 6:26
Original issue reported on code.google.com by
prasantv...@gmail.com
on 5 Nov 2015 at 8:49Attachments: