Skip to content

Self Registration

Joshua Selsky edited this page Aug 19, 2013 · 6 revisions

What does it do?

This API should be used to get the Terms of Service if they are going to be displayed to the user as well as the public key for the ReCaptcha widget.

URI

registration/read

Access Rules

Anyone may call this API.

Input Parameters

Example POST

POST /app/registration/read HTTP/1.1
 Host: dev.ohmage.org
 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7
 Content-Length: byte-length-of-content
 Content-Type: application/x-www-form-urlencoded

cURL Example

curl -v http://localhost:8080/app/registration/read

Output Format

Success

{
    "result" : "success",
    "data" : {
        "terms_of_service" : "<Terms of Service>",
        "recaptcha_public_key" : "<ReCaptcha Public Key>"
    }
}

Failure

See the error page for a description of error codes and their associated descriptions.

↑ Back to Top

What does it do?

This creates a new, disabled account. The account must then be activated via user/activation.

URI

user/register

Access Rules

Anyone may call this API.

Input Parameters

  • (r) username = The new user's username.
  • (r) password = The new user's plaintext password.
  • (r) email_address = The new user's email address.
  • (r) recaptcha_challenge_field = The challenge field generated by the ReCaptcha widget.
  • (r) recaptcha_response_field = The response field generated by the ReCaptcha widget that is the user's response to the challenge.

Example POST

POST /app/user/register HTTP/1.1
 Host: dev.ohmage.org
 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7
 Content-Length: byte-length-of-content
 Content-Type: application/x-www-form-urlencoded

 username=new.user
 &password=new.password
 &[email protected]
 &recaptcha_challenge_field=83w8oh4wh7kwh489jq3l9j3l48h8l2h4l
 &recaptcha_response_field=YeOldeAnswer

cURL Example

curl -v -d "username=new.user&password=new.password&[email protected]&recaptcha_challenge_field=83w8oh4wh7kwh489jq3l9j3l48h8l2h4l&recaptcha_response_field=YeOldeAnswer" http://localhost:8080/app/user/register

Output Format

Success

{
    "result" : "success"
}

Along with the success result, the user will receive an email at the supplied email address which will have an activation link.

Failure

See the error page for a description of error codes and their associated descriptions.

↑ Back to Top

What does it do?

Activates an account that was recently registered. Users have a limited time to click the activation link before their activation request is no longer valid.

URI

user/activate

Access Rules

Anyone may call this API, and it is expected that the caller is doing so from a link in an email.

Input Parameters

  • (r) registration_id = The registration ID sent in the link to the user.

Example POST

POST /app/user/activate HTTP/1.1
 Host: dev.ohmage.org
 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7
 Content-Length: byte-length-of-content
 Content-Type: application/x-www-form-urlencoded

 registration_id=76e87c6de788ef54d4c536de55fdeduefede54e54d34de32c45de34d56f58e709dc9e90

cURL Example

curl -v -d "registration_id=76e87c6de788ef54d4c536de55fdeduefede54e54d34de32c45de34d56f58e709dc9e900" http://localhost:8080/app/user/activate

Output Format

Success

{
    "result" : "success"
}

Failure

See the error page for a description of error codes and their associated descriptions.

↑ Back to Top

What does it do?

Given a username and email address, this will reset the user's password. If the username and email address match, an email with a new, temporary password will be sent to the user. The next time they attempt to login with that password, it will prompt them to change it. If the user doesn't exist or the email address and username don't match up, "success" will still be returned because this call doesn't require authentication, and we don't want someone to be able to spam out server for email addresses.

URI

user/reset_password

Access Rules

Anyone may call this API. The username must match a user's username exactly, but the email address will be case insensitive.

Input Parameters

  • (r) username = The username of the user whose password is to be reset.
  • (r) email_address = The email address of the user whose password is to be reset.

Example POST

POST /app/user/reset_password HTTP/1.1
 Host: dev.ohmage.org
 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7
 Content-Length: byte-length-of-content
 Content-Type: application/x-www-form-urlencoded

 username=test.user
 [email protected]

cURL Example

curl -v -d "username=test.user&[email protected]" http://localhost:8080/app/user/reset_password

Output Format

Success

{
    "result" : "success"
}

Failure

See the error page for a description of error codes and their associated descriptions.

↑ Back to Top