Insufficient permission Site verification Google
Question: I want to use python and the verification site api (v1) to verify website in
my webmaster tools. In this example I want to get all verified sites using the
verification api, because that function doesn't have parameters. (I know that
it's possible via the webmaster tools, as well)

    
    
    #!/usr/bin/python
    
    import httplib2
    
    from apiclient import errors
    from apiclient.discovery import build
    from oauth2client.client import OAuth2WebServerFlow
    from oauth2client.file import Storage
    
    http = httplib2.Http()
    
    storage = Storage('credentials')
    storage_verify = Storage('credentials_verify')
    
    credentials = storage.get()
    credentials_verify = storage_verify.get()
    
    http_wm = credentials.authorize(http)
    http_sv = credentials_verify.authorize(http)
    
    webmasters_service = build('webmasters', 'v3', http=http_wm)
    verification_service = build('siteVerification', 'v1', http=http_sv)
    
    site_list = webmasters_service.sites().list().execute()
    print(site_list)
    
    # this line generates the error     
    verified_site_list = verification_service.webResource().list().execute()
    print(verified_site_list)
    

There is an insufficient permission error:

    
    
     googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/siteVerification/v1/webResource?alt=json returned "Insufficient Permission">
    

I have read and write access for the siteVerification api (I've checked my
token here:
`https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=TOKEN` )

Any ideas what I'm doing wrong or how I can debug the code?


Answer: Make sure you read and understand <https://developers.google.com/site-
verification/v1/invoking> in its entirety. Especially you need to appreciate:

> Verify a new site
>
> To verify a site,
>  
>  
>     - First request a verification token by calling getToken.
>     - Place the token on your site using whatever method you choose.
>     - Ask Google to verify that the site is yours, using the insert
> operation.
>  

All you need to do is properly construct two requests, `getToken` and
`insert`. What "properly" means, is discussed in all detail in the docs I
linked above.

If you really need help with code, you need to show a minimal working example
so that we can reproduce the error you retrieve.

