Navigation

Meta

Maintainers

This library allows you to easily:* Generate SSO token for creating SSO users / logging them into UserVoice (http://uservoice.com).* Do 3-legged and 2-legged UserVoice API calls safely without having to worry about the cryptographic details (unless you want).

Installation============

Install the uservoice Python module from PyPI:

pip install uservoice

or get the source from (http://pypi.python.org/pypi/uservoice) and use the setup.py method:

SSO-token can be used to create sessions for SSO users. They are capable of synchronizing the user information from one system to another.Generating the SSO token from SSO key and given uservoice subdomain can be done by calling UserVoice.generate\_sso\_token method like this:

print 'Forum "{name}" created! URL: {url}'.format(**forum)except uservoice.Unauthorized as e: # Thrown usually due to faulty tokens, untrusted client or if attempting # operations without Admin Privileges print eexcept uservoice.NotFound as e: # Thrown when attempting an operation to a resource that does not exist print e

Verifying a UserVoice user--------------------------

If you want to make calls on behalf of a user, but want to make sure he or sheactually owns certain email address in UserVoice, you need to use 3-Legged APIcalls. Just pass your user an authorize link to click, so that user may grantyour site permission to access his or her data in UserVoice.

# At this point you want to print/redirect to client.authorize_url in your application.# Here we just output them as this is a command-line example.print "1. Go to {url} and click \"Allow access\".".format(url=client.authorize_url())print "2. Then type the oauth_verifier which is passed as a GET parameter to the callback URL:"

# In a web app we would get the oauth_verifier via a redirection to CALLBACK_URL.# In this command-line example we just read it from stdin:access_token = client.login_with_verifier(raw_input())

# To reuse the access token at a later point, store the token and secret. For example:# 1. Find user (in Django)u = User.objects.get(email=user['email'])# 2. Associate token and secret with the useru.access_tokens.create(system='uservoice', token=access_token.token, secret=access_token.secret)

# When you need the token again:# 1. Find token of the current usertoken = u.access_tokens.get(system='uservoice')# 2. Use the token and secret to log inaccess_token = client.login_with_access_token(token.token, token.secret)