0

I've created a service account from the initial guide and am using the same sample code published on the Google Surveys GitHub repo.

I see that I have to add my service account email as an owner to the individual survey from other answers to get the results, but so far this isn't working. It looks like an email is sent to that address to verify ownership, but nothing is sent to me. Is there another way to confirm this please?

I'm using the correct credentials JSON file in oauth.py but all requests return the following:

Error fetching survey results: <HttpError 403 when requesting https://www.googleapis.com/surveys/v2/surveys/{id}/results?alt=media returned "Forbidden">

Am I missing something? Thanks in advance for any help.

rpbbp
  • 3
  • 2
  • Can you provide more error details from the 403? – Maia Werbos Mar 13 '17 at 16:45
  • Thanks. `e.content` returns `User is not an owner of this survey. Request Id: {id}` `e.resp` returns `{'status': '403', 'content-length': '143', 'x-xss-protection': '1; mode=block', 'x-content-type-options': 'nosniff', 'transfer-encoding': 'chunked', 'expires': 'Tue, 14 Mar 2017 16:06:09 GMT', 'vary': 'Origin, X-Origin', 'server': 'GSE', '-content-encoding': 'gzip', 'cache-control': 'private, max-age=0', 'date': 'Tue, 14 Mar 2017 16:06:09 GMT', 'x-frame-options': 'SAMEORIGIN', 'alt-svc': 'quic=":443"; ma=2592000; v="36,35,34"', 'content-type': 'text/html; charset=UTF-8'}` – rpbbp Mar 14 '17 at 16:05

1 Answers1

0

To check the current owners of the survey, you have two options:

1) Google Surveys UI. Click on the survey on the Your Surveys page. Next, click on the Confirm Survey tab and look at the Details section at the bottom of the page. This will show you the current owners of the survey, and give you the option to add one.

2) Use the OAuth Playground (the Getting Started Guide has detailed directions). Call "get" on the survey to see its owners list (see "Send a GET request to examine a survey").

You can use the API to update the owners without the need for a confirmation email.

  • Follow the directions in the Getting Started Guide to set up the OAuth Playground with credentials attached to the Google account that owns this particular survey.
  • Then, use the PUT method on your survey to update the owners. Make a request in the OAuth Playground with:
    • HTTP Method: PUT
    • Request URI: https://www.googleapis.com/surveys/v2/surveys/{survey id}
    • Enter request body: { "owners": ["my_service_account@something.gserviceaccount.com"] }

Hope this helps! I'm on the Google Surveys team; if you have any further issues, feel free to send me the request ID for your failed request, so I can debug in more detail.

Maia Werbos
  • 164
  • 9
  • Thanks for your help with this. The problem is I can't share the survey with the service account. There is no confirm surveys tab I can see. When I click a survey, and attempt to add an owner through the share button, the service account email address won't persist as an owner. When I share with an email address I can check the inbox of, I have to manually accept the invitation. Could this be why? Will look into using OAuth as well. – rpbbp Mar 15 '17 at 12:13
  • I see what you're saying. You're right, sharing via the UI won't work, since you can't check the service account email. You'll need to update the owners using the API instead. I edited my answer to add directions for this - please see above. – Maia Werbos Mar 15 '17 at 17:48
  • Thank you - this works. Appreciate the help. In the future, it would be great to be able to share from the UI, or allow a service account access to all surveys on an account. – rpbbp Mar 17 '17 at 10:42
  • We'll consider that! Another option for you, if you create the survey via the API, is to add the service account to the owners list when you first create the survey. – Maia Werbos Mar 20 '17 at 17:44