![]() |
Lately we’ve been talking to a lot of customers who want to have their users be auto-logged into ReviewRoom. Take for example a university that has their own internal system for students. Such an institution typically would not want to have their students create yet another username/password just so they can apply to some scholarships and awards. |
While there are a lot of solutions to this particular situation, using the ReviewRoom API, your IT team can very quickly paste in some code into your system that will allow your applicants to auto-log-in to ReviewRoom once they are already logged into your site.
import json
from urllib import urlencode
from urllib2 import urlopen
reviewroom_url = ” # Your ReviewRoom URL
signin_path = ‘/api/signin/’
auth_path = ‘/api/authenticate/’
signin_url = ‘%s%s’ % (reviewroom_url, signin_path)
auth_url = ‘%s%s’ % (reviewroom_url, auth_path)
admin_email = ” # Your ReviewRoom’s owner’s email address
admin_password = ” # Your ReviewRoom’s owner’s password
”’
Authenticate with the API. This will return a rolling token
that should be included with all subsequent requests.
API authentication details can be found at:
http://test01.myreviewroom.com/api/docs/#authentication
”’
credentials = urlencode({
‘email’: admin_email,
‘password’: admin_password,
})
”’
Send our credentials via HTTP POST, this will authenticate with the ReviewRoom API.
”’
response = urlopen(auth_url, credentials).read()
token = json.loads(response)['token']
”’
The following values are required by the `sign in` API method.
The most important field being `email`, which will govern what
user this is.
”’
data = urlencode({
‘email’: ”, # Email address of applicant
‘group’: ”, # ID of applicant group to assign this applicant to
‘first_name’: ”, # First name of applicant
‘last_name’: ”, # Last name of applicant
‘token’: token # API token
})
”’
Send the information about our user to the ReviewRoom API’s sign-in method.
If a user with the given email exists, a one-time-login URL will be returned.
If a user account with the given email does not exist, a new account will be created.
Both scenarios will return the same response.
”’
response = urlopen(signin_url, data).read()
return_path = json.loads(response)['return_path']
”’
The client should now be redirected to `return_path`, via an HTTP redirect or other means.
`return_path` is a use-once URL that will automatically sign the client in to ReviewRoom.
”’
print return_path


