Clean up samples and remove Buzz references.
diff --git a/samples/appengine/app.yaml b/samples/appengine/app.yaml
index 03bdf81..bdc4be1 100644
--- a/samples/appengine/app.yaml
+++ b/samples/appengine/app.yaml
@@ -1,15 +1,11 @@
-application: m-buzz
-version: 1
+application: jcg-testing-01
+version: 2
 runtime: python
 api_version: 1
 
 handlers:
-- url: /static
-  static_dir: static
-
-- url: /google8f1adb368b7bd14c.html
-  upload: google8f1adb368b7bd14c.html
-  static_files: static/google8f1adb368b7bd14c.html
+- url: /oauth2callback
+  script: oauth2client/appengine.py
 
 - url: .*
   script: main.py
diff --git a/samples/appengine/client_secrets.json b/samples/appengine/client_secrets.json
new file mode 100644
index 0000000..a232f37
--- /dev/null
+++ b/samples/appengine/client_secrets.json
@@ -0,0 +1,9 @@
+{
+  "web": {
+    "client_id": "[[INSERT CLIENT ID HERE]]",
+    "client_secret": "[[INSERT CLIENT SECRET HERE]]",
+    "redirect_uris": [],
+    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
+    "token_uri": "https://accounts.google.com/o/oauth2/token"
+  }
+}
diff --git a/samples/appengine/grant.html b/samples/appengine/grant.html
new file mode 100644
index 0000000..0087325
--- /dev/null
+++ b/samples/appengine/grant.html
@@ -0,0 +1,17 @@
+<html>
+  <head>
+    <title>Can Haz Perms?</title>
+  </head>
+  <body>
+    {% if has_credentials %}
+    <p>Thanks for granting us permission. Please <a href="/about">proceed to the main
+      application</a>.</p>
+    {% else %}
+    <p><a href="{{ url }}">Grant</a> this application permission to read your
+    Buzz information and it will let you know how many followers you have.</p>
+    {% endif %}
+    <p>You can always <a
+      href="https://www.google.com/accounts/b/0/IssuedAuthSubTokens">revoke</a>
+    permission at any time.</p>
+  </body>
+</html>
diff --git a/samples/appengine/main.py b/samples/appengine/main.py
old mode 100755
new mode 100644
index 184f5fa..309376c
--- a/samples/appengine/main.py
+++ b/samples/appengine/main.py
@@ -14,6 +14,13 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
+"""Starting template for Google App Engine applications.
+
+Use this project as a starting point if you are just beginning to build a Google
+App Engine project. Remember to download the OAuth 2.0 client secrets which can
+be obtained from the Developer Console <https://code.google.com/apis/console/>
+and save them as 'client_secrets.json' in the project directory.
+"""
 
 __author__ = 'jcgregorio@google.com (Joe Gregorio)'
 
@@ -24,84 +31,79 @@
 import pickle
 
 from apiclient.discovery import build
-from oauth2client.appengine import CredentialsProperty
-from oauth2client.appengine import StorageByKeyName
-from oauth2client.client import OAuth2WebServerFlow
+from oauth2client.appengine import oauth2decorator_from_clientsecrets
+from oauth2client.client import AccessTokenRefreshError
 from google.appengine.api import memcache
-from google.appengine.api import users
-from google.appengine.ext import db
 from google.appengine.ext import webapp
 from google.appengine.ext.webapp import template
-from google.appengine.ext.webapp import util
-from google.appengine.ext.webapp.util import login_required
+from google.appengine.ext.webapp.util import run_wsgi_app
 
 
-FLOW = OAuth2WebServerFlow(
-    # Visit https://code.google.com/apis/console to
-    # generate your client_id, client_secret and to
-    # register your redirect_uri.
-    client_id='<YOUR CLIENT ID HERE>',
-    client_secret='<YOUR CLIENT SECRET HERE>',
-    scope='https://www.googleapis.com/auth/buzz',
-    user_agent='buzz-cmdline-sample/1.0')
+# CLIENT_SECRETS, name of a file containing the OAuth 2.0 information for this
+# application, including client_id and client_secret, which are found
+# on the API Access tab on the Google APIs
+# Console <http://code.google.com/apis/console>
+CLIENT_SECRETS = os.path.join(os.path.dirname(__file__), 'client_secrets.json')
+
+# Helpful message to display in the browser if the CLIENT_SECRETS file
+# is missing.
+MISSING_CLIENT_SECRETS_MESSAGE = """
+<h1>Warning: Please configure OAuth 2.0</h1>
+<p>
+To make this sample run you will need to populate the client_secrets.json file
+found at:
+</p>
+<p>
+<code>%s</code>.
+</p>
+<p>with information found on the <a
+href="https://code.google.com/apis/console">APIs Console</a>.
+</p>
+""" % CLIENT_SECRETS
 
 
-class Credentials(db.Model):
-  credentials = CredentialsProperty()
-
+http = httplib2.Http(memcache)
+service = build("plus", "v1", http=http)
+decorator = oauth2decorator_from_clientsecrets(
+    CLIENT_SECRETS,
+    'https://www.googleapis.com/auth/plus.me',
+    MISSING_CLIENT_SECRETS_MESSAGE)
 
 class MainHandler(webapp.RequestHandler):
 
-  @login_required
+  @decorator.oauth_aware
   def get(self):
-    user = users.get_current_user()
-    credentials = StorageByKeyName(
-        Credentials, user.user_id(), 'credentials').get()
+    path = os.path.join(os.path.dirname(__file__), 'grant.html')
+    variables = {
+        'url': decorator.authorize_url(),
+        'has_credentials': decorator.has_credentials()
+        }
+    self.response.out.write(template.render(path, variables))
 
-    if credentials is None or credentials.invalid == True:
-      callback = self.request.relative_url('/oauth2callback')
-      authorize_url = FLOW.step1_get_authorize_url(callback)
-      memcache.set(user.user_id(), pickle.dumps(FLOW))
-      self.redirect(authorize_url)
-    else:
-      http = httplib2.Http()
-      http = credentials.authorize(http)
-      service = build("buzz", "v1", http=http)
-      activities = service.activities()
-      activitylist = activities.list(scope='@consumption',
-                                     userId='@me').execute()
+
+class AboutHandler(webapp.RequestHandler):
+
+  @decorator.oauth_required
+  def get(self):
+    try:
+      http = decorator.http()
+      user = service.people().get(userId='me').execute(http)
+      text = 'Hello, %s!' % user['displayName']
+
       path = os.path.join(os.path.dirname(__file__), 'welcome.html')
-      logout = users.create_logout_url('/')
-      self.response.out.write(
-          template.render(
-              path, {'activitylist': activitylist,
-                     'logout': logout
-                     }))
-
-
-class OAuthHandler(webapp.RequestHandler):
-
-  @login_required
-  def get(self):
-    user = users.get_current_user()
-    flow = pickle.loads(memcache.get(user.user_id()))
-    if flow:
-      credentials = flow.step2_exchange(self.request.params)
-      StorageByKeyName(
-          Credentials, user.user_id(), 'credentials').put(credentials)
-      self.redirect("/")
-    else:
-      pass
+      self.response.out.write(template.render(path, {'text': text }))
+    except AccessTokenRefreshError:
+      self.redirect('/')
 
 
 def main():
   application = webapp.WSGIApplication(
       [
-      ('/', MainHandler),
-      ('/oauth2callback', OAuthHandler)
+       ('/', MainHandler),
+       ('/about', AboutHandler),
       ],
       debug=True)
-  util.run_wsgi_app(application)
+  run_wsgi_app(application)
 
 
 if __name__ == '__main__':
diff --git a/samples/appengine/simplejson b/samples/appengine/simplejson
deleted file mode 120000
index 148c7cf..0000000
--- a/samples/appengine/simplejson
+++ /dev/null
@@ -1 +0,0 @@
-../../simplejson/
\ No newline at end of file
diff --git a/samples/appengine/static/go.png b/samples/appengine/static/go.png
deleted file mode 100644
index e5aacda..0000000
--- a/samples/appengine/static/go.png
+++ /dev/null
Binary files differ
diff --git a/samples/appengine/welcome.html b/samples/appengine/welcome.html
index da40a16..57b186e 100644
--- a/samples/appengine/welcome.html
+++ b/samples/appengine/welcome.html
@@ -1,29 +1,8 @@
 <html>
   <head>
-    <title>Buzz Stuff</title>
-    <style type=text/css>
-      td  { vertical-align: top; padding: 0.5em }
-      img { border:0 }
-    </style>
+    <title>Welcome</title>
   </head>
   <body>
-    <p><a href="{{ logout }}">Logout</a></p>
-      <table border=0>
-      {% for item in activitylist.items %}
-      <tr valign=top>
-        <td>
-          <a href="{{ item.actor.profileUrl }}"><img
-            src="{{ item.actor.thumbnailUrl }}"></a><br>
-          <a href="{{ item.actor.profileUrl }}">{{ item.actor.name }}</a></td>
-      <td>
-        {{ item.object.content }}
-        </td>
-        <td>
-          <a href="{{ item.object.links.alternate.0.href }}"><img
-            src="/static/go.png"></a>
-        </td>
-      </tr>
-      {% endfor %}
-      </table>
+    <p>{{ text }}</p>
   </body>
 </html>