I am trying to connect Streamsets to Google Analytics. However I am having trouble setting it up. With a regular CURL request I would do the following:
Step 1) Go to the following link to get the authorization code:
https://accounts.google.com/o/oauth2/auth?client_id={CLIENTID}.apps.googleusercontent.com&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=https://www.googleapis.com/auth/analytics&response_type=code
Step 2) Do a post request to fetch the access & refreshment tokens
curl -i -v --request POST -H "Content-Type: application/x-www-form-urlencoded" -d "code={AUTHORIZATION CODE FROM STEP 1}&client_id={CLIENT ID}.apps.googleusercontent.com&client_secret={CLIENT SECREP}&scope=https://www.googleapis.com/auth/analytics&grant_type=authorization_code&redirect_uri=urn:ietf:wg:oauth:2.0:oob" https://accounts.google.com/o/oauth2/token
Step 3)
Do the actual curl request:
curl -X POST -H "Authorization: Bearer ya29.{AUTH RESPONSE}" -H "Content-Type: application/json" --data "{\"reportRequests\": [{\"viewId\": \"ga:{NUMBER}\",\"dateRanges\": [{\"start_date\": \"2016-01-01\", \"endDate\": \"yesterday\"}],\"metrics\": [{\"expression\":\"ga:sessions\"}], \"dimensions\": [{\"name\":\"ga:dimensions2\"}, {\"name\":\"ga:dimensions3\"}],\"samplingLevel\": \"LARGE\",\"pageToken\": \"\", \"pageSize\": 10000}]}" https://analyticsreporting.googleapis.com/v4/reports:batchGet
And in Streamsets I tried to set it up like this: (I am using images because it is easier to follow.)
1) I put the resource URL the same as step 3, where I fetch the data
2) The Request body is also the same as in step 3
3) And this is the OAuth2 screen. I blurred the credentials.
However I still don't know how to fetch my data. I am not receiving any output and to fetch the data with a CURL request seems to me like a 3 step process, not a 2 step one (as it seems to be in Streamsets). Is Streamsets able to fetch this or should i write a origin of my own? Because to me it seems at first sight that it is not able to do this. I have read both the Streamsets and Google Analytics manuals but they haven't really helped me a lot.
Thank you in advance.