| <!DOCTYPE html> | |
| <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> | |
| <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Working with User Data — Apache Usergrid 2.x documentation</title> | |
| <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> | |
| <link rel="top" title="Apache Usergrid 2.x documentation" href="../index.html"/> | |
| <link rel="next" title="Working with group data" href="group.html"/> | |
| <link rel="prev" title="User management & social graph" href="user-management.html"/> | |
| <script src="../_static/js/modernizr.min.js"></script> | |
| </head> | |
| <body class="wy-body-for-nav" role="document"> | |
| <div class="wy-grid-for-nav"> | |
| <nav data-toggle="wy-nav-shift" class="wy-nav-side"> | |
| <div class="wy-side-nav-search"> | |
| <a href="../index.html" class="icon icon-home"> Apache Usergrid | |
| </a> | |
| <div class="version"> | |
| 2.x | |
| </div> | |
| <div role="search"> | |
| <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> | |
| <input type="text" name="q" placeholder="Search docs" /> | |
| <input type="hidden" name="check_keywords" value="yes" /> | |
| <input type="hidden" name="area" value="default" /> | |
| </form> | |
| </div> | |
| </div> | |
| <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> | |
| <p class="caption"><span class="caption-text">Getting Started</span></p> | |
| <ul> | |
| <li class="toctree-l1"><a class="reference internal" href="../introduction/overview.html">Getting Started</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../introduction/usergrid-features.html">Usergrid Features</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../introduction/data-model.html">Usergrid Data model</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../introduction/async-vs-sync.html">Async vs. sync calls</a></li> | |
| </ul> | |
| <p class="caption"><span class="caption-text">Using Usergrid</span></p> | |
| <ul> | |
| <li class="toctree-l1"><a class="reference internal" href="../using-usergrid/creating-account.html">Creating a Usergrid Account</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../using-usergrid/creating-a-new-application.html">Creating a new application</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../using-usergrid/using-a-sandbox-app.html">Using a Sandbox Application</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../using-usergrid/using-the-api.html">Using the API</a></li> | |
| </ul> | |
| <p class="caption"><span class="caption-text">Data Storage</span></p> | |
| <ul> | |
| <li class="toctree-l1"><a class="reference internal" href="../data-storage/data-store-dbms.html">The Usergrid Data Store</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../data-storage/optimizing-access.html">Data Store Best Practices</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../data-storage/collections.html">Collections</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../data-storage/entities.html">Entities</a></li> | |
| </ul> | |
| <p class="caption"><span class="caption-text">Data Queries</span></p> | |
| <ul> | |
| <li class="toctree-l1"><a class="reference internal" href="../data-queries/querying-your-data.html">Querying your data</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../data-queries/query-parameters.html">Query parameters & clauses</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../data-queries/operators-and-types.html">Query operators & data types</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../data-queries/advanced-query-usage.html">Advanced query usage</a></li> | |
| </ul> | |
| <p class="caption"><span class="caption-text">Entity Connections</span></p> | |
| <ul> | |
| <li class="toctree-l1"><a class="reference internal" href="../entity-connections/connecting-entities.html">Connecting entities</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../entity-connections/retrieving-entities.html">Retrieving connections</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../entity-connections/disconnecting-entities.html">Disconnecting entities</a></li> | |
| </ul> | |
| <p class="caption"><span class="caption-text">Push Notifications</span></p> | |
| <ul> | |
| <li class="toctree-l1"><a class="reference internal" href="../push-notifications/overview.html">Push notifications overview</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../push-notifications/adding-push-support.html">Adding push notifications support</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../push-notifications/getting-started.html">Getting started with push notifications</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../push-notifications/tutorial.html">Tutorial: Push notifications sample app</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../push-notifications/registering.html">Registering with a notification service</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../push-notifications/creating-notifiers.html">Creating notifiers</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../push-notifications/managing-users-and-devices.html">Managing users and devices</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../push-notifications/creating-and-managing-notifications.html">Creating and managing notifications</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../push-notifications/troubleshooting.html">Troubleshooting</a></li> | |
| </ul> | |
| <p class="caption"><span class="caption-text">Security & Authentication</span></p> | |
| <ul> | |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/app-security.html">Security & token authentication</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/using-permissions.html">Using permissions</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/using-roles.html">Using roles</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/authenticating-users-and-application-clients.html">Authenticating users & app clients</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/user-authentication-types.html">Authentication levels</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/changing-token-time-live-ttl.html">Changing token expiration (time-to-live)</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/authenticating-api-requests.html">Authenticating API requests</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/revoking-tokens-logout.html">Revoking tokens (logout)</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/facebook-sign.html">Facebook sign in</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../security-and-auth/securing-your-app.html">Security best practices</a></li> | |
| </ul> | |
| <p class="caption"><span class="caption-text">User Management & Social Graph</span></p> | |
| <ul class="current"> | |
| <li class="toctree-l1"><a class="reference internal" href="user-management.html">User management & social graph</a></li> | |
| <li class="toctree-l1 current"><a class="current reference internal" href="">Working with User Data</a><ul> | |
| <li class="toctree-l2"><a class="reference internal" href="#creating-users">Creating users</a><ul> | |
| <li class="toctree-l3"><a class="reference internal" href="#request-syntax">Request Syntax</a></li> | |
| <li class="toctree-l3"><a class="reference internal" href="#request-uri">Request URI</a></li> | |
| <li class="toctree-l3"><a class="reference internal" href="#example">Example</a></li> | |
| <li class="toctree-l3"><a class="reference internal" href="#request">Request</a></li> | |
| <li class="toctree-l3"><a class="reference internal" href="#response">Response</a></li> | |
| </ul> | |
| </li> | |
| <li class="toctree-l2"><a class="reference internal" href="#retrieving-user-data">Retrieving user data</a><ul> | |
| <li class="toctree-l3"><a class="reference internal" href="#id1">Request Syntax</a></li> | |
| <li class="toctree-l3"><a class="reference internal" href="#id2">Request URI</a></li> | |
| <li class="toctree-l3"><a class="reference internal" href="#id3">Example</a></li> | |
| </ul> | |
| </li> | |
| <li class="toctree-l2"><a class="reference internal" href="#updating-deleting-user-data">Updating & deleting user data</a></li> | |
| <li class="toctree-l2"><a class="reference internal" href="#changing-a-user-password">Changing a user password</a><ul> | |
| <li class="toctree-l3"><a class="reference internal" href="#id4">Request syntax</a></li> | |
| </ul> | |
| </li> | |
| <li class="toctree-l2"><a class="reference internal" href="#resetting-a-user-password">Resetting a user password</a><ul> | |
| <li class="toctree-l3"><a class="reference internal" href="#step-1-get-the-password-reset-request-form">STEP 1: Get the password reset request form.</a></li> | |
| <li class="toctree-l3"><a class="reference internal" href="#step-2-display-the-returned-password-reset-request-form-to-the-user">STEP 2: Display the returned password reset request form to the user.</a></li> | |
| <li class="toctree-l3"><a class="reference internal" href="#step-3-let-usergrid-handle-the-rest">STEP 3: Let Usergrid handle the rest!</a></li> | |
| </ul> | |
| </li> | |
| </ul> | |
| </li> | |
| <li class="toctree-l1"><a class="reference internal" href="group.html">Working with group data</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="activity.html">Activity</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="user-connections.html">Social Graph Connections</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="user-connections.html#creating-other-connections">Creating other connections</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="messagee-example.html">App Example - Messagee</a></li> | |
| </ul> | |
| <p class="caption"><span class="caption-text">Geo-location</span></p> | |
| <ul> | |
| <li class="toctree-l1"><a class="reference internal" href="../geolocation/geolocation.html">Geolocating your Entities</a></li> | |
| </ul> | |
| <p class="caption"><span class="caption-text">Assets & Files</span></p> | |
| <ul> | |
| <li class="toctree-l1"><a class="reference internal" href="../assets-and-files/uploading-assets.html">Uploading assets</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../assets-and-files/retrieving-assets.html">Retrieving assets</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../assets-and-files/folders.html">Folders</a></li> | |
| </ul> | |
| <p class="caption"><span class="caption-text">Counters & Events</span></p> | |
| <ul> | |
| <li class="toctree-l1"><a class="reference internal" href="../counters-and-events/events-and-counters.html">Counters & events</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../counters-and-events/creating-and-incrementing-counters.html">Creating & incrementing counters</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../counters-and-events/creating-and-incrementing-counters.html#decrementing-resetting-counters">Decrementing/resetting counters</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../counters-and-events/creating-and-incrementing-counters.html#using-counters-hierarchically">Using counters hierarchically</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../counters-and-events/retrieving-counters.html">Retrieving counters</a></li> | |
| </ul> | |
| <p class="caption"><span class="caption-text">Organizations & Applications</span></p> | |
| <ul> | |
| <li class="toctree-l1"><a class="reference internal" href="../orgs-and-apps/managing.html">Organization & application management</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../orgs-and-apps/organization.html">Organization</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../orgs-and-apps/application.html">Application</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../orgs-and-apps/admin-user.html">Admin user</a></li> | |
| </ul> | |
| <p class="caption"><span class="caption-text">API Reference</span></p> | |
| <ul> | |
| <li class="toctree-l1"><a class="reference internal" href="../rest-endpoints/api-docs.html">Methods</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../rest-endpoints/api-docs.html#models">Models</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../rest-endpoints/api-docs.html#sub-types">Sub-Types</a></li> | |
| </ul> | |
| <p class="caption"><span class="caption-text">Client SDKs</span></p> | |
| <ul> | |
| <li class="toctree-l1"><a class="reference internal" href="../sdks/tbd.html">COMING SOON...</a></li> | |
| </ul> | |
| <p class="caption"><span class="caption-text">Installing Usergrid</span></p> | |
| <ul> | |
| <li class="toctree-l1"><a class="reference internal" href="../installation/deployment-guide.html">Usergrid 2.1.0 Deployment Guide</a></li> | |
| </ul> | |
| <p class="caption"><span class="caption-text">More about Usergrid</span></p> | |
| <ul> | |
| <li class="toctree-l1"><a class="reference internal" href="../reference/presos-and-videos.html">Presentations & Videos</a></li> | |
| <li class="toctree-l1"><a class="reference internal" href="../reference/contribute-code.html">How to Contribute Code & Docs</a></li> | |
| </ul> | |
| </div> | |
| | |
| </nav> | |
| <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> | |
| <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> | |
| <i data-toggle="wy-nav-top" class="fa fa-bars"></i> | |
| <a href="../index.html">Apache Usergrid</a> | |
| </nav> | |
| <div class="wy-nav-content"> | |
| <div class="rst-content"> | |
| <div role="navigation" aria-label="breadcrumbs navigation"> | |
| <ul class="wy-breadcrumbs"> | |
| <li><a href="../index.html">Docs</a> »</li> | |
| <li>Working with User Data</li> | |
| <li class="wy-breadcrumbs-aside"> | |
| <a href="../_sources/user-management/working-user-data.txt" rel="nofollow"> View page source</a> | |
| </li> | |
| </ul> | |
| <hr/> | |
| </div> | |
| <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> | |
| <div itemprop="articleBody"> | |
| <div class="section" id="working-with-user-data"> | |
| <h1>Working with User Data<a class="headerlink" href="#working-with-user-data" title="Permalink to this headline">¶</a></h1> | |
| <p>You can store and manage user data as User entities. With user data in | |
| your application, you can add support for a wide variety of features | |
| common to mobile apps. For example, you can:</p> | |
| <ul class="simple"> | |
| <li>Control access to data by defining permission rules. (See <a class="reference external" href="../security-and-auth/app-security.html">Security & | |
| token authentication</a> for | |
| more.)</li> | |
| <li>Present content specific to each user, such as their list of | |
| favorites.</li> | |
| <li>Support social features, such as letting users “follow” one another, | |
| for example.</li> | |
| </ul> | |
| <p>In mobile applications, data about users is typically added by users | |
| themselves when they register through your app. The topics in this | |
| section provide specific cURL and SDK-specific examples for getting | |
| things done with user data.</p> | |
| <div class="section" id="creating-users"> | |
| <h2>Creating users<a class="headerlink" href="#creating-users" title="Permalink to this headline">¶</a></h2> | |
| <p>A user entity represents an application user. Using API Services you can | |
| create, retrieve, update, delete, and query user entities. See <a class="reference external" href="../rest-endpoints/api-doc.html#user">User | |
| entity properties</a> for a list of | |
| the system-defined properties for user entities. In addition, you can | |
| create user properties specific to your application.</p> | |
| <div class="section" id="request-syntax"> | |
| <h3>Request Syntax<a class="headerlink" href="#request-syntax" title="Permalink to this headline">¶</a></h3> | |
| <div class="highlight-python"><div class="highlight"><pre>curl -X POST "https://api.usergrid.com/your-org/your-app/users" -d '{ "username": "john.doe", "email": "john.doe@gmail.com", "name": "John Doe", "password": "test1234" }' | |
| </pre></div> | |
| </div> | |
| <p>Use the POST method to create a new user in the users collection.</p> | |
| </div> | |
| <div class="section" id="request-uri"> | |
| <h3>Request URI<a class="headerlink" href="#request-uri" title="Permalink to this headline">¶</a></h3> | |
| <div class="highlight-python"><div class="highlight"><pre>POST /<org_id>/<app_id>/users | |
| </pre></div> | |
| </div> | |
| <p>Parameters</p> | |
| <table border="1" class="docutils"> | |
| <colgroup> | |
| <col width="31%" /> | |
| <col width="69%" /> | |
| </colgroup> | |
| <thead valign="bottom"> | |
| <tr class="row-odd"><th class="head">Parameter</th> | |
| <th class="head">Description</th> | |
| </tr> | |
| </thead> | |
| <tbody valign="top"> | |
| <tr class="row-even"><td>uuid | org_id</td> | |
| <td>Organization UUID or organization name.</td> | |
| </tr> | |
| <tr class="row-odd"><td>uuid | app_id</td> | |
| <td>Application UUID or application name.</td> | |
| </tr> | |
| <tr class="row-even"><td>request body</td> | |
| <td>One or more sets of user properties.</td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| <p>The username is mandatory and must be unique. Here’s an example:</p> | |
| <div class="highlight-python"><div class="highlight"><pre><span class="p">{</span> | |
| <span class="s">"username"</span> <span class="p">:</span> <span class="s">"john.doe"</span><span class="p">,</span> | |
| <span class="s">"email"</span> <span class="p">:</span> <span class="s">"john.doe@gmail.com"</span><span class="p">,</span> | |
| <span class="s">"name"</span> <span class="p">:</span> <span class="s">"John Doe"</span><span class="p">,</span> | |
| <span class="s">"password"</span> <span class="p">:</span> <span class="s">"test1234"</span> | |
| <span class="p">}</span> | |
| </pre></div> | |
| </div> | |
| <p>Although the password parameter is not mandatory, if you don’t specify | |
| it, the user will not be able to log in using username and password | |
| credentials. If a password is not specified for the user, and you’re an | |
| Admin, you can set a password for the user (see <a class="reference external" href="#changing-a-user-password">Changing a User | |
| Password</a>).</p> | |
| <p>__ Note__: The username can contain any combination of characters, | |
| including those that represent letters, numbers, and symbols.</p> | |
| </div> | |
| <div class="section" id="example"> | |
| <h3>Example<a class="headerlink" href="#example" title="Permalink to this headline">¶</a></h3> | |
| <p><strong>Note</strong>: Although not shown in the API examples below, you need to | |
| provide a valid access token with each API call. See <a class="reference external" href="../security-and-auth/authenticating-users-and-application-clients.html">Authenticating | |
| users and application | |
| clients</a> | |
| for details.</p> | |
| </div> | |
| <div class="section" id="request"> | |
| <h3>Request<a class="headerlink" href="#request" title="Permalink to this headline">¶</a></h3> | |
| <div class="highlight-python"><div class="highlight"><pre>curl -X POST "https://api.usergrid.com/my-org/my-app/users" -d '{"username":"john.doe","email":"john.doe@gmail.com","name":"John Doe"}' | |
| </pre></div> | |
| </div> | |
| </div> | |
| <div class="section" id="response"> | |
| <h3>Response<a class="headerlink" href="#response" title="Permalink to this headline">¶</a></h3> | |
| <div class="highlight-python"><div class="highlight"><pre><span class="p">{</span> | |
| <span class="s">"action"</span> <span class="p">:</span> <span class="s">"post"</span><span class="p">,</span> | |
| <span class="s">"application"</span> <span class="p">:</span> <span class="s">"db1e60a0-417f-11e3-9586-0f1ff3650d20"</span><span class="p">,</span> | |
| <span class="s">"params"</span> <span class="p">:</span> <span class="p">{</span> <span class="p">},</span> | |
| <span class="s">"path"</span> <span class="p">:</span> <span class="s">"/users"</span><span class="p">,</span> | |
| <span class="s">"uri"</span> <span class="p">:</span> <span class="s">"https://api.usergrid.com/steventraut/mynewapp/users"</span><span class="p">,</span> | |
| <span class="s">"entities"</span> <span class="p">:</span> <span class="p">[</span> <span class="p">{</span> | |
| <span class="s">"uuid"</span> <span class="p">:</span> <span class="s">"8ae8a6ea-84a5-11e3-884d-f18e8f6fb3bc"</span><span class="p">,</span> | |
| <span class="s">"type"</span> <span class="p">:</span> <span class="s">"user"</span><span class="p">,</span> | |
| <span class="s">"name"</span> <span class="p">:</span> <span class="s">"John Doe"</span><span class="p">,</span> | |
| <span class="s">"created"</span> <span class="p">:</span> <span class="mi">1390533228622</span><span class="p">,</span> | |
| <span class="s">"modified"</span> <span class="p">:</span> <span class="mi">1390533228622</span><span class="p">,</span> | |
| <span class="s">"username"</span> <span class="p">:</span> <span class="s">"john.doe"</span><span class="p">,</span> | |
| <span class="s">"email"</span> <span class="p">:</span> <span class="s">"john.doe@gmail.com"</span><span class="p">,</span> | |
| <span class="s">"activated"</span> <span class="p">:</span> <span class="n">true</span><span class="p">,</span> | |
| <span class="s">"picture"</span> <span class="p">:</span> <span class="s">"http://www.gravatar.com/avatar/e13743a7f1db7f4246badd6fd6ff54ff"</span><span class="p">,</span> | |
| <span class="s">"metadata"</span> <span class="p">:</span> <span class="p">{</span> | |
| <span class="s">"path"</span> <span class="p">:</span> <span class="s">"/users/8ae8a6ea-84a5-11e3-884d-f18e8f6fb3bc"</span><span class="p">,</span> | |
| <span class="s">"sets"</span> <span class="p">:</span> <span class="p">{</span> | |
| <span class="s">"rolenames"</span> <span class="p">:</span> <span class="s">"/users/8ae8a6ea-84a5-11e3-884d-f18e8f6fb3bc/roles"</span><span class="p">,</span> | |
| <span class="s">"permissions"</span> <span class="p">:</span> <span class="s">"/users/8ae8a6ea-84a5-11e3-884d-f18e8f6fb3bc/permissions"</span> | |
| <span class="p">},</span> | |
| <span class="s">"collections"</span> <span class="p">:</span> <span class="p">{</span> | |
| <span class="s">"activities"</span> <span class="p">:</span> <span class="s">"/users/8ae8a6ea-84a5-11e3-884d-f18e8f6fb3bc/activities"</span><span class="p">,</span> | |
| <span class="s">"devices"</span> <span class="p">:</span> <span class="s">"/users/8ae8a6ea-84a5-11e3-884d-f18e8f6fb3bc/devices"</span><span class="p">,</span> | |
| <span class="s">"feed"</span> <span class="p">:</span> <span class="s">"/users/8ae8a6ea-84a5-11e3-884d-f18e8f6fb3bc/feed"</span><span class="p">,</span> | |
| <span class="s">"groups"</span> <span class="p">:</span> <span class="s">"/users/8ae8a6ea-84a5-11e3-884d-f18e8f6fb3bc/groups"</span><span class="p">,</span> | |
| <span class="s">"roles"</span> <span class="p">:</span> <span class="s">"/users/8ae8a6ea-84a5-11e3-884d-f18e8f6fb3bc/roles"</span><span class="p">,</span> | |
| <span class="s">"following"</span> <span class="p">:</span> <span class="s">"/users/8ae8a6ea-84a5-11e3-884d-f18e8f6fb3bc/following"</span><span class="p">,</span> | |
| <span class="s">"followers"</span> <span class="p">:</span> <span class="s">"/users/8ae8a6ea-84a5-11e3-884d-f18e8f6fb3bc/followers"</span> | |
| <span class="p">}</span> | |
| <span class="p">}</span> | |
| <span class="p">}],</span> | |
| <span class="s">"timestamp"</span> <span class="p">:</span> <span class="mi">1390533228619</span><span class="p">,</span> | |
| <span class="s">"duration"</span> <span class="p">:</span> <span class="mi">142</span><span class="p">,</span> | |
| <span class="s">"organization"</span> <span class="p">:</span> <span class="s">"my-org"</span><span class="p">,</span> | |
| <span class="s">"applicationName"</span> <span class="p">:</span> <span class="s">"my-app"</span> | |
| <span class="p">}</span> | |
| </pre></div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="section" id="retrieving-user-data"> | |
| <h2>Retrieving user data<a class="headerlink" href="#retrieving-user-data" title="Permalink to this headline">¶</a></h2> | |
| <p>You can retrieve data about users through cURL or one of the SDKs. Each | |
| provides a way to filter the list of users by data associated with the | |
| user, such as username or UUID, or other properties in the user entity.</p> | |
| <p>See <a class="reference external" href="../rest-endpoints/api-doc.html#user">User entity properties</a> for | |
| a list of the system-defined properties for user entities. In addition, | |
| you can create user properties specific to your application.</p> | |
| <div class="section" id="id1"> | |
| <h3>Request Syntax<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h3> | |
| <div class="highlight-python"><div class="highlight"><pre>curl -X GET "https://api.usergrid.com/your-org/your-app/users" | |
| </pre></div> | |
| </div> | |
| <p>Use the GET method to retrieve user data.</p> | |
| </div> | |
| <div class="section" id="id2"> | |
| <h3>Request URI<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h3> | |
| <div class="highlight-python"><div class="highlight"><pre>GET /<org_id>/<app_id>/users/<uuid | username | email_address | ?ql=query_string> | |
| </pre></div> | |
| </div> | |
| <p>Parameters</p> | |
| <table border="1" class="docutils"> | |
| <colgroup> | |
| <col width="31%" /> | |
| <col width="69%" /> | |
| </colgroup> | |
| <thead valign="bottom"> | |
| <tr class="row-odd"><th class="head">Parameter</th> | |
| <th class="head">Description</th> | |
| </tr> | |
| </thead> | |
| <tbody valign="top"> | |
| <tr class="row-even"><td>uuid | org_id</td> | |
| <td>Organization UUID or organization name</td> | |
| </tr> | |
| <tr class="row-odd"><td>uuid | app_id</td> | |
| <td>Application UUID or application name</td> | |
| </tr> | |
| <tr class="row-even"><td>user identifier</td> | |
| <td>User UUID, username, or email address.</td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| <p>The alias <code class="docutils literal"><span class="pre">/users/me</span></code> can be used in place of the current user’s uuid, | |
| username, or email address. Note: The <code class="docutils literal"><span class="pre">/users/me</span></code> endpoint is | |
| accessible only if you provide an access token with the request (see | |
| <a class="reference external" href="../security-and-auth/authenticating-users-and-application-clients.html">Authenticating users and application | |
| clients</a>). | |
| If you make an anonymous (“guest”) call, the system will not be able to | |
| determine which user to return as <code class="docutils literal"><span class="pre">/users/me</span></code>.</p> | |
| <p><strong>Note</strong>: The username can contain any combination of characters, | |
| including those that represent letters, numbers, and symbols.</p> | |
| </div> | |
| <div class="section" id="id3"> | |
| <h3>Example<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h3> | |
| <p><strong>Note</strong>: Although not shown in the API examples below, you need to | |
| provide a valid access token with each API call. See <a class="reference external" href="../security-and-auth/authenticating-users-and-application-clients.html">Authenticating | |
| users and application | |
| clients</a> | |
| for details.</p> | |
| <p>Requests</p> | |
| <div class="highlight-python"><div class="highlight"><pre># Get a user by username. | |
| curl -X GET "https://api.usergrid.com/my-org/my-app/users/jane.doe" | |
| # Get a user by UUID. | |
| curl -X GET "https://api.usergrid.com/my-org/my-app/users/a407b1e7-58e8-11e1-ac46-22000a1c5a67e" | |
| # Get a user by email. | |
| curl -X GET "https://api.usergrid.com/my-org/my-app/users/jane.doe@gmail.com" | |
| # Get user data filtering by their city property value. | |
| curl -X GET "https://api.usergrid.com/my-org/my-app/users?ql=select%20*%20where%20adr.city%3D'Chicago'" | |
| </pre></div> | |
| </div> | |
| <p>Response</p> | |
| <div class="highlight-python"><div class="highlight"><pre>{ | |
| "action" : "get", | |
| "application" : "1c8f60e4-da67-11e0-b93d-12313f0204bb8", | |
| "params" : { | |
| "_": [ | |
| "1315524419746" | |
| ] | |
| }, | |
| "path" : "https://api.usergrid.com/12313f0204bb-1c8f60e4-da67-11e0-b93d/1c8f60e4-da67-11e0-b93d-12313f0204bb/users", | |
| "uri" : "https://api.usergrid.com/005056c00008-4353136f-e978-11e0-8264/4353136f-e978-11e0-8264-005056c00008/users", | |
| "entities" : [ { | |
| "uuid" : "78c54a82-da71-11e0-b93d-12313f0204b", | |
| "type" : "user", | |
| "created" : 1315524171347008, | |
| "modified" : 1315524171347008, | |
| "activated" : true, | |
| "email" : "jane.doe@gmail.com", | |
| "metadata" : { | |
| "path" : "/users/78c54a82-da71-11e0-b93d-12313f0204bb", | |
| "sets" : { | |
| "rolenames" : "/users/78c54a82-da71-11e0-b93d-12313f0204bb/rolenames", | |
| "permissions" : "/users/78c54a82-da71-11e0-b93d-12313f0204bb/permissions" | |
| }, | |
| "collections" : { | |
| "activities" : "/users/78c54a82-da71-11e0-b93d-12313f0204bb/activities", | |
| "devices" : "/users/78c54a82-da71-11e0-b93d-12313f0204bb/devices", | |
| "feed" : "/users/78c54a82-da71-11e0-b93d-12313f0204bb/feed", | |
| "groups" : "/users/78c54a82-da71-11e0-b93d-12313f0204bb/groups", | |
| "roles" : "/users/78c54a82-da71-11e0-b93d-12313f0204bb/roles", | |
| "following" : "/users/78c54a82-da71-11e0-b93d-12313f0204bb/following", | |
| "followers" : "/users/78c54a82-da71-11e0-b93d-12313f0204bb/followers" | |
| } | |
| }, | |
| "username" : "jane.doe" | |
| } | |
| ... Additional entities here if data for multiple users was returned... | |
| ], | |
| "timestamp" : 1315524421071, | |
| "duration" : 107, | |
| "organization" : "my-org", | |
| "applicationName": "my-app" | |
| } | |
| </pre></div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="section" id="updating-deleting-user-data"> | |
| <h2>Updating & deleting user data<a class="headerlink" href="#updating-deleting-user-data" title="Permalink to this headline">¶</a></h2> | |
| <p>To update or delete a user, perform an update or delete on the | |
| associated user entity as you would any other entity. For more | |
| information and code samples, see <a class="reference external" href="../data-storage/entities.html#updating-data-entities">Updating Data | |
| Entities</a> and | |
| <a class="reference external" href="../data-storage/entities.html#deleting-data-entities">Deleting Data | |
| Entities</a>.</p> | |
| </div> | |
| <div class="section" id="changing-a-user-password"> | |
| <h2>Changing a user password<a class="headerlink" href="#changing-a-user-password" title="Permalink to this headline">¶</a></h2> | |
| <p>Changing a user’s password</p> | |
| <div class="section" id="id4"> | |
| <h3>Request syntax<a class="headerlink" href="#id4" title="Permalink to this headline">¶</a></h3> | |
| <div class="highlight-python"><div class="highlight"><pre>curl -X PUT https://api.usergrid.com/<org>/<app>/users/<username_or_email>/password -d '{oldpassword:<old_password>,newpassword:<new_password>}' | |
| </pre></div> | |
| </div> | |
| <p>Parameters</p> | |
| <table border="1" class="docutils"> | |
| <colgroup> | |
| <col width="24%" /> | |
| <col width="76%" /> | |
| </colgroup> | |
| <thead valign="bottom"> | |
| <tr class="row-odd"><th class="head">Parameter</th> | |
| <th class="head">Description</th> | |
| </tr> | |
| </thead> | |
| <tbody valign="top"> | |
| <tr class="row-even"><td>org</td> | |
| <td>Organization UUID or organization name</td> | |
| </tr> | |
| <tr class="row-odd"><td>app</td> | |
| <td>Application UUID or application name</td> | |
| </tr> | |
| <tr class="row-even"><td>username_or_email</td> | |
| <td>Username or email of the user entity whose password you want to reset.</td> | |
| </tr> | |
| <tr class="row-odd"><td>old_password</td> | |
| <td>User entity’s old password.</td> | |
| </tr> | |
| <tr class="row-even"><td>new_password</td> | |
| <td>User entity’s new password.</td> | |
| </tr> | |
| </tbody> | |
| </table> | |
| <p><strong>Note</strong>: If your request is authenticated with an application-level | |
| token, then <code class="docutils literal"><span class="pre">old_password</span></code> is not required. For more, see <a class="reference external" href="../security-and-auth/authenticating-users-and-application-clients.html#application-client-authentication">Application | |
| client | |
| authentication</a>.</p> | |
| <p>Example request</p> | |
| <div class="highlight-python"><div class="highlight"><pre>curl -X PUT https://api.usergrid.com/my-org/my-app/users/john.doe/password -d '{"newpassword":"foo9876a","oldpassword":"bar1234b"}' | |
| </pre></div> | |
| </div> | |
| <p>Example response</p> | |
| <div class="highlight-python"><div class="highlight"><pre><span class="p">{</span> | |
| <span class="s">"action"</span><span class="p">:</span> <span class="s">"set user password"</span><span class="p">,</span> | |
| <span class="s">"timestamp"</span><span class="p">:</span> <span class="mi">1355185897894</span><span class="p">,</span> | |
| <span class="s">"duration"</span><span class="p">:</span> <span class="mi">47</span> | |
| <span class="p">}</span> | |
| </pre></div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="section" id="resetting-a-user-password"> | |
| <h2>Resetting a user password<a class="headerlink" href="#resetting-a-user-password" title="Permalink to this headline">¶</a></h2> | |
| <p>Resetting a user’s password</p> | |
| <p>Usergrid provides a standard password reset flow that can be implemented | |
| to allow a user to reset their password without having to provide their | |
| old password. The most common use of this would be a ‘Forgot password?’ | |
| feature in your app.</p> | |
| <p>Note that you can also implement your own password reset flow using | |
| application-level authentication and the /password endpoint. For more, | |
| see <a class="reference external" href="#changing-a-user-password">Changing a user password</a>.</p> | |
| <p>To use the Usergrid password reset flow, do the following:</p> | |
| <div class="section" id="step-1-get-the-password-reset-request-form"> | |
| <h3>STEP 1: Get the password reset request form.<a class="headerlink" href="#step-1-get-the-password-reset-request-form" title="Permalink to this headline">¶</a></h3> | |
| <p>Make a GET request to the following:</p> | |
| <div class="highlight-python"><div class="highlight"><pre>/users/<username>/resetpw | |
| </pre></div> | |
| </div> | |
| <p>For example, using cURL, a request to reset the password for a user with | |
| username ‘someUser’ would look like this:</p> | |
| <div class="highlight-python"><div class="highlight"><pre>curl -x GET https://api.usergrid.com/your-org/your-app/users/someUser/resetpw | |
| </pre></div> | |
| </div> | |
| </div> | |
| <div class="section" id="step-2-display-the-returned-password-reset-request-form-to-the-user"> | |
| <h3>STEP 2: Display the returned password reset request form to the user.<a class="headerlink" href="#step-2-display-the-returned-password-reset-request-form-to-the-user" title="Permalink to this headline">¶</a></h3> | |
| <p>The request to <code class="docutils literal"><span class="pre">/resetpw</span></code> will return the HTML for the standard | |
| Usergrid password reset request form that you will display to your user. | |
| The request form requires the users to provide their username as well as | |
| answer a standard CAPTCHA challenge:</p> | |
| <div class="highlight-python"><div class="highlight"><pre><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | |
| <html> | |
| <head> | |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> | |
| <title>Reset Password</title> | |
| <link rel="stylesheet" type="text/css" href="/css/styles.css" /> | |
| </head> | |
| <body> | |
| <div class="dialog-area"> | |
| <form class="dialog-form" action="" method="post"> | |
| <fieldset> | |
| <p> | |
| Enter the captcha to have your password reset instructions sent to | |
| someUser@adomain.com | |
| </p> | |
| <p id="human-proof"></p> | |
| <script type="text/javascript" src="https://www.google.com/recaptcha/api/challenge?k=6LdSTNESAAAAAKHdVglHmMu86_EoYxsJjqQD1IpZ"></script> | |
| <p class="buttons"> | |
| <input type="submit" value="submit" /> | |
| </p> | |
| </fieldset> | |
| </form> | |
| </div> | |
| </body> | |
| </html> | |
| </pre></div> | |
| </div> | |
| <p>You can apply any additional styling you wish to the form to make it | |
| match the style of your app before displaying it to the user.</p> | |
| </div> | |
| <div class="section" id="step-3-let-usergrid-handle-the-rest"> | |
| <h3>STEP 3: Let Usergrid handle the rest!<a class="headerlink" href="#step-3-let-usergrid-handle-the-rest" title="Permalink to this headline">¶</a></h3> | |
| <p>Once the user submits the form with their username, they will receive an | |
| email from Usergrid that contains a link to the password reset form, | |
| where they can specify a new password. The user entity will be updated | |
| immediately.</p> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <footer> | |
| <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> | |
| <a href="group.html" class="btn btn-neutral float-right" title="Working with group data" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a> | |
| <a href="user-management.html" class="btn btn-neutral" title="User management & social graph" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a> | |
| </div> | |
| <hr/> | |
| <div role="contentinfo"> | |
| <p> | |
| © Copyright 2013-2015, Apache Usergrid. | |
| </p> | |
| </div> | |
| Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. | |
| </footer> | |
| </div> | |
| </div> | |
| </section> | |
| </div> | |
| <script type="text/javascript"> | |
| var DOCUMENTATION_OPTIONS = { | |
| URL_ROOT:'../', | |
| VERSION:'2.x', | |
| COLLAPSE_INDEX:false, | |
| FILE_SUFFIX:'.html', | |
| HAS_SOURCE: true | |
| }; | |
| </script> | |
| <script type="text/javascript" src="../_static/jquery.js"></script> | |
| <script type="text/javascript" src="../_static/underscore.js"></script> | |
| <script type="text/javascript" src="../_static/doctools.js"></script> | |
| <script type="text/javascript" src="../_static/js/theme.js"></script> | |
| <script type="text/javascript"> | |
| jQuery(function () { | |
| SphinxRtdTheme.StickyNav.enable(); | |
| }); | |
| </script> | |
| </body> | |
| </html> |