/
ExamplegetWorkSpaces.py
36 lines (28 loc) · 1.29 KB
/
ExamplegetWorkSpaces.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import oAuth
import huddleApi
import user
import os
huddleAuthServer = "http://FOO.COM"
huddleApiServer = "http://BAR.COM"
consumer_key = "foo"
redirect_uri = "bar"
def run_example():
#first lets get the auth code from the client
request_token_url = huddleAuthServer + "request?response_type=code" + "&client_id=" + consumer_key + "&redirect_uri=" + redirect_uri
print "Get Your Authorization Code and paste it back into python\n" + request_token_url
code = raw_input('--> ')
auth = oAuth.oAuth(huddleAuthServer, code, consumer_key, redirect_uri)
#store our access token
tokenStore = auth.handleAccessToken()
#now we can make calls to the api
api = huddleApi.huddleApi(huddleApiServer, tokenStore)
getWorkspaces = user.user(api.getUser())
print "You currently have " + str(getWorkspaces.getWorkSpaceSize()) + " workspaces!"
for i in range(getWorkspaces.getWorkSpaceSize()):
print "\nWorkspace : " + str(getWorkspaces.getWorkSpaceTitle(i)) + " has the following links: "
for x in range(getWorkspaces.getWorkSpaceLinks(i)):
print getWorkspaces.getWorkSpaceLinkRel(i, x) + ":" + getWorkspaces.getWorkSpaceLinkHref(i, x)
os.system("pause")
if __name__ == '__main__':
run_example()
print 'Done.'