| OLD | NEW |
| 1 This directory contains an example app ("cloudauth") that demonstrates | 1 This directory contains an example app ("cloudauth") that demonstrates |
| 2 how to use an OAUTH2 flow within a web app to authorize App Engine access | 2 how to use an OAUTH2 flow within a web app to authorize App Engine access |
| 3 to Google Storage. | 3 to Google Storage. |
| 4 | 4 |
| 5 To install and try the app, take the following steps: | 5 To install and try the app, take the following steps: |
| 6 | 6 |
| 7 1. The current code assumes you are already familiar with Google | 7 1. The current code assumes you are already familiar with Google |
| 8 App Engine, and and have the App Engine SDK installed. If that's not | 8 App Engine, and and have the App Engine SDK installed. If that's not |
| 9 true, start at http://code.google.com/appengine/ | 9 true, start at http://code.google.com/appengine/ |
| 10 | 10 |
| 11 In the remainder of these instructions, we assume | 11 In the remainder of these instructions, we assume |
| 12 you have gsutil unpacked in /usr/local/gsutil, Google | 12 you have gsutil unpacked in /usr/local/gsutil, Google |
| 13 App Engine installed at /usr/local/google_appengine, and | 13 App Engine installed at /usr/local/google_appengine, and |
| 14 http://pypi.python.org/pypi/google-api-python-client/1.0beta1 installed | 14 http://pypi.python.org/pypi/google-api-python-client/1.0beta1 installed |
| 15 at /usr/local/google-api-python-client | 15 at /usr/local/google-api-python-client |
| 16 | 16 |
| 17 2. Copy the boto, cloudauth, and needed parts of the | 17 2. Copy the boto, cloudauth, and needed parts of the |
| 18 google-api-python-client code into the google_appengine directory: | 18 google-api-python-client code into the google_appengine directory: |
| 19 % cp -pr /usr/local/gsutil/cloudauth /usr/local/google_appengine | 19 % cp -pr /usr/local/gsutil/cloudauth /usr/local/google_appengine |
| 20 % cp -pr /usr/local/gsutil/boto /usr/local/google_appengine/cloudauth | 20 % cp -pr /usr/local/gsutil/boto/boto /usr/local/google_appengine/cloudauth |
| 21 % cp -pr /usr/local/google-api-python-client/{apiclient,httplib2,oauth2clie
nt,gflags*.py} \ | 21 % cp -pr /usr/local/google-api-python-client-1.0beta1/{apiclient,httplib2,o
auth2client,gflags*.py} \ |
| 22 /usr/local/google_appengine/cloudauth | 22 /usr/local/google_appengine/cloudauth |
| 23 | 23 |
| 24 3. Go to the Developer Console and create a project (see | 24 3. Go to the Google APIs Console and create a project (see |
| 25 http://code.google.com/apis/console-help/). Then, click | 25 http://code.google.com/apis/console-help/). Then, click |
| 26 the "API Access" tab and then the "Create an OAuth2 client | 26 the "API Access" tab and then the "Create an OAuth2 client |
| 27 ID..." button. Enter a product name and click next, select "Web | 27 ID..." button. Enter a product name and click next, select "Web |
| 28 application", and then enter the host "http://localhost:8080", and | 28 application", and then enter the host "http://localhost:8080", and |
| 29 click "Create client ID". Then click "Edit settings" and change the | 29 click "Create client ID". Then click "Edit settings" and change the |
| 30 Authorized Redirect URIs to be https://localhost:8080/auth_return. | 30 Authorized Redirect URIs to be http://localhost:8080/auth_return. |
| 31 (You'll need to update these values when you move from running | 31 (You'll need to update these values when you move from running |
| 32 this app locally to running on App Engine.) Then copy the client | 32 this app locally to running on App Engine.) Then copy the Client |
| 33 id and secret key from this dialog into the corresponding values in | 33 ID and Client secret from this dialog into the corresponding values in |
| 34 /usr/local/google_appengine/cloudauth/cloudauth.py. Note that these | 34 /usr/local/google_appengine/cloudauth/cloudauth.py. Note that these |
| 35 values do not enable access until coupled with an OAUTH2 refresh token | 35 values do not enable access until coupled with an OAUTH2 refresh token |
| 36 that will be generated by the OAUTH2 flow implemented in this web app - | 36 that will be generated by the OAUTH2 flow implemented in this web app - |
| 37 so it's safe to save the "secret key" value in your code. | 37 so it's safe to save the "secret key" value in your code. |
| 38 | 38 |
| 39 4. Try running it: | 39 4. Try running it: |
| 40 % cd /usr/local/google_appengine | 40 % cd /usr/local/google_appengine |
| 41 % ./dev_appserver.py cloudauth | 41 % ./dev_appserver.py cloudauth |
| 42 and then open your browser to http://localhost:8080 | 42 and then open your browser to http://localhost:8080 |
| 43 | 43 |
| 44 If it works, you should see the object loaded. | 44 If it works, you should see the object loaded. |
| 45 | 45 |
| 46 5. At this point you can upload your app to Google | 46 5. At this point you can upload your app to Google |
| 47 infrastructure, following the instructions at | 47 infrastructure, following the instructions at |
| 48 http://code.google.com/appengine/docs/python/gettingstarted/uploading.html | 48 http://code.google.com/appengine/docs/python/gettingstarted/uploading.html |
| 49 | 49 |
| 50 6. You can see documentation about the OAUTH2 client library at | 50 6. You can see documentation about the OAUTH2 client library at |
| 51 http://code.google.com/p/google-api-python-client/wiki/OAuth2 | 51 http://code.google.com/p/google-api-python-client/wiki/OAuth2 |
| OLD | NEW |