Moved OAuth discovery data into future.json
This commit is contained in:
@@ -4,4 +4,4 @@ syntax: glob
|
||||
.*.swp
|
||||
*/.git/*
|
||||
.gitignore
|
||||
oauth_token.dat
|
||||
samples/cmdline/*.dat
|
||||
|
||||
@@ -3,6 +3,59 @@
|
||||
"buzz": {
|
||||
"v1": {
|
||||
"baseUrl": "https://www.googleapis.com/",
|
||||
"auth": {
|
||||
"request": {
|
||||
"url": "https://www.google.com/accounts/OAuthGetRequestToken",
|
||||
"parameters": {
|
||||
"xoauth_displayname": {
|
||||
"parameterType": "query",
|
||||
"required": false
|
||||
},
|
||||
"domain": {
|
||||
"parameterType": "query",
|
||||
"required": true
|
||||
},
|
||||
"scope": {
|
||||
"parameterType": "query",
|
||||
"required": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"authorize": {
|
||||
"url": "https://www.google.com/buzz/api/auth/OAuthAuthorizeToken",
|
||||
"parameters": {
|
||||
"oauth_token": {
|
||||
"parameterType": "query",
|
||||
"required": true
|
||||
},
|
||||
"iconUrl": {
|
||||
"parameterType": "query",
|
||||
"required": false
|
||||
},
|
||||
"domain": {
|
||||
"parameterType": "query",
|
||||
"required": true
|
||||
},
|
||||
"scope": {
|
||||
"parameterType": "query",
|
||||
"required": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"access": {
|
||||
"url": "https://www.google.com/accounts/OAuthGetAccessToken",
|
||||
"parameters": {
|
||||
"domain": {
|
||||
"parameterType": "query",
|
||||
"required": true
|
||||
},
|
||||
"scope": {
|
||||
"parameterType": "query",
|
||||
"required": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"resources": {
|
||||
"activities": {
|
||||
"methods": {
|
||||
|
||||
@@ -3,6 +3,59 @@
|
||||
"latitude": {
|
||||
"v1": {
|
||||
"baseUrl": "https://www.googleapis.com/",
|
||||
"auth": {
|
||||
"request": {
|
||||
"url": "https://www.google.com/accounts/OAuthGetRequestToken",
|
||||
"parameters": {
|
||||
"xoauth_displayname": {
|
||||
"parameterType": "query",
|
||||
"required": False
|
||||
},
|
||||
"domain": {
|
||||
"parameterType": "query",
|
||||
"required": True
|
||||
},
|
||||
"scope": {
|
||||
"parameterType": "query",
|
||||
"required": True
|
||||
},
|
||||
},
|
||||
},
|
||||
"authorize": {
|
||||
"url": "https://www.google.com/latitude/apps/OAuthAuthorizeToken",
|
||||
"parameters": {
|
||||
"oauth_token": {
|
||||
"parameterType": "query",
|
||||
"required": True
|
||||
},
|
||||
"iconUrl": {
|
||||
"parameterType": "query",
|
||||
"required": False
|
||||
},
|
||||
"domain": {
|
||||
"parameterType": "query",
|
||||
"required": True
|
||||
},
|
||||
"scope": {
|
||||
"parameterType": "query",
|
||||
"required": True
|
||||
},
|
||||
},
|
||||
},
|
||||
"access": {
|
||||
"url": "https://www.google.com/accounts/OAuthGetAccessToken",
|
||||
"parameters": {
|
||||
"domain": {
|
||||
"parameterType": "query",
|
||||
"required": True
|
||||
},
|
||||
"scope": {
|
||||
"parameterType": "query",
|
||||
"required": True
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"resources": {
|
||||
"currentLocation": {
|
||||
"methods": {
|
||||
@@ -23,4 +76,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,59 @@
|
||||
"moderator": {
|
||||
"v1": {
|
||||
"baseUrl": "https://www.googleapis.com/",
|
||||
"auth": {
|
||||
"request": {
|
||||
"url": "https://www.google.com/accounts/OAuthGetRequestToken",
|
||||
"parameters": {
|
||||
"xoauth_displayname": {
|
||||
"parameterType": "query",
|
||||
"required": false
|
||||
},
|
||||
"domain": {
|
||||
"parameterType": "query",
|
||||
"required": false
|
||||
},
|
||||
"scope": {
|
||||
"parameterType": "query",
|
||||
"required": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"authorize": {
|
||||
"url": "https://www.google.com/accounts/OAuthAuthorizeToken",
|
||||
"parameters": {
|
||||
"oauth_token": {
|
||||
"parameterType": "query",
|
||||
"required": true
|
||||
},
|
||||
"iconUrl": {
|
||||
"parameterType": "query",
|
||||
"required": false
|
||||
},
|
||||
"domain": {
|
||||
"parameterType": "query",
|
||||
"required": false
|
||||
},
|
||||
"scope": {
|
||||
"parameterType": "query",
|
||||
"required": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"access": {
|
||||
"url": "https://www.google.com/accounts/OAuthGetAccessToken",
|
||||
"parameters": {
|
||||
"domain": {
|
||||
"parameterType": "query",
|
||||
"required": false
|
||||
},
|
||||
"scope": {
|
||||
"parameterType": "query",
|
||||
"required": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"resources": {
|
||||
"profiles": {
|
||||
"methods": {
|
||||
@@ -57,4 +110,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,6 +112,7 @@ def build(serviceName, version, http=httplib2.Http(),
|
||||
d = simplejson.load(f)
|
||||
f.close()
|
||||
future = d['data'][serviceName][version]['resources']
|
||||
auth_discovery = d['data'][serviceName][version]['auth']
|
||||
|
||||
base = service['baseUrl']
|
||||
resources = service['resources']
|
||||
@@ -124,6 +125,9 @@ def build(serviceName, version, http=httplib2.Http(),
|
||||
self._baseUrl = base
|
||||
self._model = model
|
||||
|
||||
def auth_discovery(self):
|
||||
return auth_discovery
|
||||
|
||||
def createMethod(theclass, methodName, methodDesc, futureDesc):
|
||||
|
||||
def method(self, **kwargs):
|
||||
|
||||
@@ -29,61 +29,6 @@ def _abstract():
|
||||
raise NotImplementedError('You need to override this function')
|
||||
|
||||
|
||||
buzz_discovery = {
|
||||
'request': {
|
||||
'url': 'https://www.google.com/accounts/OAuthGetRequestToken',
|
||||
'parameters': {
|
||||
'xoauth_displayname': {
|
||||
'parameterType': 'query',
|
||||
'required': False
|
||||
},
|
||||
'domain': {
|
||||
'parameterType': 'query',
|
||||
'required': True
|
||||
},
|
||||
'scope': {
|
||||
'parameterType': 'query',
|
||||
'required': True
|
||||
},
|
||||
},
|
||||
},
|
||||
'authorize': {
|
||||
'url': 'https://www.google.com/buzz/api/auth/OAuthAuthorizeToken',
|
||||
'parameters': {
|
||||
'oauth_token': {
|
||||
'parameterType': 'query',
|
||||
'required': True
|
||||
},
|
||||
'iconUrl': {
|
||||
'parameterType': 'query',
|
||||
'required': False
|
||||
},
|
||||
'domain': {
|
||||
'parameterType': 'query',
|
||||
'required': True
|
||||
},
|
||||
'scope': {
|
||||
'parameterType': 'query',
|
||||
'required': True
|
||||
},
|
||||
},
|
||||
},
|
||||
'access': {
|
||||
'url': 'https://www.google.com/accounts/OAuthGetAccessToken',
|
||||
'parameters': {
|
||||
'domain': {
|
||||
'parameterType': 'query',
|
||||
'required': True
|
||||
},
|
||||
'scope': {
|
||||
'parameterType': 'query',
|
||||
'required': True
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def _oauth_uri(name, discovery, params):
|
||||
"""Look up the OAuth UR from the discovery
|
||||
document and add query parameters based on
|
||||
|
||||
@@ -19,7 +19,7 @@ import pickle
|
||||
|
||||
|
||||
def main():
|
||||
f = open("oauth_token.dat", "r")
|
||||
f = open("buzz.dat", "r")
|
||||
credentials = pickle.loads(f.read())
|
||||
f.close()
|
||||
|
||||
|
||||
33
samples/cmdline/moderator.py
Normal file
33
samples/cmdline/moderator.py
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/python2.4
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2010 Google Inc. All Rights Reserved.
|
||||
|
||||
"""Simple command-line example for Buzz.
|
||||
|
||||
Command-line application that retrieves the users
|
||||
latest content and then adds a new entry.
|
||||
"""
|
||||
|
||||
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
|
||||
|
||||
|
||||
from apiclient.discovery import build
|
||||
|
||||
import httplib2
|
||||
import pickle
|
||||
|
||||
|
||||
def main():
|
||||
f = open("moderator.dat", "r")
|
||||
credentials = pickle.loads(f.read())
|
||||
f.close()
|
||||
|
||||
http = httplib2.Http()
|
||||
http = credentials.authorize(http)
|
||||
|
||||
p = build("moderator", "v1", http=http)
|
||||
print p.submissions().list(seriesId="7035", topicId="64")
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -22,11 +22,13 @@ other example apps in the same directory.
|
||||
|
||||
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
|
||||
|
||||
from apiclient.oauth import buzz_discovery
|
||||
from apiclient.discovery import build
|
||||
from apiclient.oauth import FlowThreeLegged
|
||||
|
||||
import pickle
|
||||
|
||||
buzz_discovery = build("buzz", "v1").auth_discovery()
|
||||
|
||||
flow = FlowThreeLegged(buzz_discovery,
|
||||
consumer_key='anonymous',
|
||||
consumer_secret='anonymous',
|
||||
@@ -48,6 +50,6 @@ verification = raw_input('What is the verification code? ').strip()
|
||||
|
||||
credentials = flow.step2_exchange(verification)
|
||||
|
||||
f = open('oauth_token.dat', 'w')
|
||||
f = open('buzz.dat', 'w')
|
||||
f.write(pickle.dumps(credentials))
|
||||
f.close()
|
||||
|
||||
55
samples/cmdline/three_legged_dance_moderator.py
Normal file
55
samples/cmdline/three_legged_dance_moderator.py
Normal file
@@ -0,0 +1,55 @@
|
||||
# Copyright (C) 2010 Google Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""Do the OAuth 1.0a three legged dance.
|
||||
|
||||
Do the OAuth 1.0a three legged dance for
|
||||
a Buzz command line application. Store the generated
|
||||
credentials in a common file that is used by
|
||||
other example apps in the same directory.
|
||||
"""
|
||||
|
||||
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
|
||||
|
||||
from apiclient.discovery import build
|
||||
from apiclient.oauth import FlowThreeLegged
|
||||
|
||||
import pickle
|
||||
|
||||
moderator_discovery = build("moderator", "v1").auth_discovery()
|
||||
|
||||
flow = FlowThreeLegged(moderator_discovery,
|
||||
consumer_key='anonymous',
|
||||
consumer_secret='anonymous',
|
||||
user_agent='google-api-client-python-mdrtr-cmdline/1.0',
|
||||
domain='anonymous',
|
||||
scope='https://www.googleapis.com/auth/moderator',
|
||||
xoauth_displayname='Google API Client Example App')
|
||||
|
||||
authorize_url = flow.step1_get_authorize_url()
|
||||
|
||||
print 'Go to the following link in your browser:'
|
||||
print authorize_url
|
||||
print
|
||||
|
||||
accepted = 'n'
|
||||
while accepted.lower() == 'n':
|
||||
accepted = raw_input('Have you authorized me? (y/n) ')
|
||||
verification = raw_input('What is the verification code? ').strip()
|
||||
|
||||
credentials = flow.step2_exchange(verification)
|
||||
|
||||
f = open('moderator.dat', 'w')
|
||||
f.write(pickle.dumps(credentials))
|
||||
f.close()
|
||||
Reference in New Issue
Block a user