Contents |
URL
https://api.geoloqi.com/1/user/create
Description
Create a new account given an email address and username. Returns the OAuth access token. This method is for the "sign up" feature of mobile clients.
Authentication
You must provide the API Key (Client ID) for this method, but the API Secret is not required. This means you do not need to include your client secret in your mobile apps.
If sending the client_id in post parameters, you can just omit the client_secret parameter. If you are using HTTP Basic Auth, you can use an empty string for the password.
Supported Request Methods
POST
Parameters
The request must be authenticated with the application's client ID and secret. You can do this by either passing them in post parameters or by using HTTP Basic auth.
- client_idYour application's client ID
Alternatively, you can pass the authentication in via HTTP Basic auth if you are using a library that supports it. Use the client ID as the username and leave the password blank. See API/Authentication for more information.
- username username or email is requiredThe user's desired username
- email username or email is requiredThe user's email address. A confirmation code will be sent to this address so the user can set up their password on their computer.
- password optionalIf provided, the user's password will be set to this value so they can log back in with a call to oauth/token. Passwords are stored securely as a sha1 hash with a unique salt.
- extraA hash of keys and values to store along with the user. Whatever you store here will be returned whenever the user profile is read. See Extra Parameters for more details.
- device_idIf the account is being created from a mobile device, a UUID should be generated and sent at this time. This UUID will also be used when sending UDP location updates.
- macIf the account is being created from a mobile device, the MAC address of the wifi adapter should be sent.
- apn_tokenFor iPhones, if the app has already registered for push notifications before calling create_anon, the token can be sent at this time.
Layers and Groups
You can automatically subscribe users to a layer or add them to a group when they are created. To do this, use the "layer_ids" and "group_tokens" parameters when creating the user.
- layer_idsAn array of one or more layer IDs the user should be subscribed to when created. The layer must be "public", since this is equivalent to immediately running layer/subscribe/:id after the account is created.
- group_tokensAn array of one or more group tokens the user should be added to when created. The groups must be "public" or "open" since this is equivalent to immediately running group/join/:token after the account is created.
Example
{ "email":"[email protected]", "extra":{ "ref":"your_key" } }
Response
Success
On successful account creation, the response is identical to a call to oauth/token and will contain an access token and refresh token. The mobile client should make sure not to lose the refresh token, since the user has no password at this point and will have no way to log in via the mobile app until creating a password on their computer.
{ "access_token": "RsT5OjbzRn430zqMAZFh+QaLgVx+Q3Ia", "expires_in": 3600, "scope": null, "refresh_token": "e1qoXgfno1YTKc7aAZvIk2RRua48lXIV" }
Error
You will get a descriptive error message if there was a problem creating the account. See Error Codes for more information.
{ "error": "username_exists", "error_description": "The requested username is not available" }