Monday, December 23, 2013

Switching to the new website verification API

Webmaster level: advanced

Just over a year ago we introduced a new API for website verification for Google services. In the spirit of keeping things simple and focusing our efforts, we've decided to deprecate the old verification API method on March 31st, 2014. The rest of the API will remain unchanged, this only affects the verification method. For more information about verification in general, please see our site verification Help Center article.

One advantage of upgrading to the new API for verification is that it uses the same client libraries as most other Google APIs, which simplifies integration with other apps and tools. Getting started is easy, especially if you're used to other Google APIs:
  1. Download the Google API client library for your favorite programming language.
  2. Learn about the Site Verification API and its methods.
  3. Allow your users to authenticate with OAuth.
  4. Start verifying!

If you can't wait to try it out and are a fan of command lines, here's a shortcut:
  1. Download and install oacurl.
  2. Authenticate with a Google Account:
    $ java -cp oacurl-1.2.0.jar com.google.oacurl.Login \
      --scope https://www.googleapis.com/auth/siteverification
  3. Request the verification information:
    $ echo '{ "verificationMethod": "FILE", "site": {
     "identifier": "http://www.example.com",
     "type": "SITE" } }' | \
     java -cp oacurl-1.2.0.jar com.google.oacurl.Fetch \
     'https://www.googleapis.com/siteVerification/v1/token' \
     --content-type JSON -X=POST
  4. Create & add the file to your website, then verify:
    $ echo '{ "site": { "identifier": "http://www.example.com",
    "type": "SITE" } }' | \
    java -cp oacurl-1.2.0.jar com.google.oacurl.Fetch \
    'https://www.googleapis.com/siteVerification/v1/webResource?verificationMethod=FILE' \
    --content-type JSON -X=POST
  5. Done!

We hope this API will make it easier to implement Google site verification in your projects. Should you have any questions, feel free to comment here, or post in our Webmaster Help Forum.