Quantcast
Channel: Blog – Stormpath User Identity API
Viewing all articles
Browse latest Browse all 278

Enrich Your User Accounts with Stormpath

$
0
0

Bonsai Sketch

While Stormpath is great for storing user accounts — did you know you can also store custom data for each user? Stormpath’s custom data makes it possible to store rich profile data and other information on a user account.

Earlier this week I sat down and built a new tool, stormpath-enrich, using our brand new Node Library.

enrich is a simple Node.js command line tool which analyzes your Stormpath user accounts, finds a plethora of information on each user (by email address), then stores this data in your user account’s custom data store.

enrich makes it incredibly easy to build rich user profiles automatically!

Enrich Your User Accounts

Let’s take a look at what enrich actually does!

Let’s say you’ve got a Stormpath Application with several user accounts, one of which has an email address, r@rdegges.com.

When you run enrich, it’ll go through each user account, and do several things:

  • Grab the user’s email address.
  • Use FullContact’s API service to search for publicly available information on this user.
  • Store whatever information is available in your Stormpath user account’s custom data store — so you can access it later.

FullContact is an extremely useful API service which scours the web for information about users by email address — it will scrape information from Facebook, Twitter, Google, etc., and return a single record with all of the user’s information.

When I run enrich on my personal account, I get the following custom data stored in my user account:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
{
  "contactInfo": {
    "familyName": "Degges",
    "fullName": "Randall Degges",
    "givenName": "Randall",
    "websites": [
      {
        "url": "http://rdegges.com"
      },
      {
        "url": "http://www.theherokuhackersguide.com/"
      },
      {
        "url": "http://www.pycall.org/"
      },
      {
        "url": "http://rdegges.com/"
      },
      {
        "url": "http://www.telephonyresearch.com/"
      }
    ]
  },
  "demographics": {                                                                                                                                                          [81/208]
    "gender": "Male",
    "locationGeneral": "California, USA"
  },
  "organizations": [
    {
      "current": false,
      "isPrimary": true,
      "name": "Telephony Research",
      "startDate": "2012",
      "title": "Chief Hacker"
    },
    {
      "current": true,
      "isPrimary": true,
      "name": "Stormpath",
      "startDate": "2014-02",
      "title": "Developer Evangelist"
    },
    {
      "current": false,
      "endDate": "2009",
      "isPrimary": false,
      "name": "Fonality",
      "startDate": "2008",
      "title": "Programmer"
    },
    {
      "current": false,
      "endDate": "2012",
      "isPrimary": false,
      "name": "BTS",
      "startDate": "2009",
      "title": "Lead Developer"
    }
  ],
  "photos": [                                                                                                                                                                [45/208]
    {
      "isPrimary": true,
      "type": "facebook",
      "typeId": "facebook",
      "typeName": "Facebook",
      "url": "https://d2ojpxxtu63wzl.cloudfront.net/static/aaf383528d6026df23bb342bbde8b295_f44fb7ef5c407df39029ef3160f4c075a0f82acfa00d30028b396922158cdc01"
    },
    {
      "isPrimary": false,
      "type": "foursquare",
      "typeId": "foursquare",
      "typeName": "Foursquare",
      "url": "https://d2ojpxxtu63wzl.cloudfront.net/static/0cb868fc5a274771605c0e0d7f955ee6_2c5fa7a99f9d322c6476ee374a22467000e88730a06aacc95e328c4e1f8071f2"
    },
    {
      "isPrimary": false,
      "type": "googleplus",
      "typeId": "googleplus",
      "typeName": "Google Plus",
      "url": "https://d2ojpxxtu63wzl.cloudfront.net/static/9c9350196801eb617b70f00b29a78b1c_91431537e46e579dcfbcfaf069196dd1817c82a34ef4481dd06e5bdc6e630601"
    },
    {
      "isPrimary": false,
      "type": "twitter",
      "typeId": "twitter",
      "typeName": "Twitter",
      "url": "https://d2ojpxxtu63wzl.cloudfront.net/static/d0f046119d0f5438924c8442eadb6f1b_2fc73d27aa217ccfb1d969847d8d53d0687986c742a86dd6173cf689ffa749c9"
    },
    {
      "isPrimary": false,
      "photoBytesMD5": "e0139f33ef023149308b26076b240c9a",
      "type": "gravatar",
      "typeId": "gravatar",
      "typeName": "Gravatar",
      "url": "https://d2ojpxxtu63wzl.cloudfront.net/static/8058dbaadafd9ea2859c84c5ecb275d7_49977cacdcd42944e609608797cf5548ba3f8b66881f97399c143212e1809314"
    },
    {
      "isPrimary": false,
      "type": "linkedin",
      "typeId": "linkedin",
      "typeName": "LinkedIn",
      "url": "https://d2ojpxxtu63wzl.cloudfront.net/static/d6ff74c0e6d4e4c48d2daf2be82fd7b8_452404fa403cf2cc1b90611542d39197f8ef7d51b02ec8e8bba3f46142535132"
    }
  ],
  "socialProfiles": [
    {
      "bio": "I'm just a happy programmer that likes to hack stuff.",
      "id": "75427646",
      "type": "foursquare",
      "typeId": "foursquare",
      "typeName": "Foursquare",
      "url": "https://www.foursquare.com/user/75427646"
    },
    {
      "id": "53099533",
      "type": "gravatar",
      "typeId": "gravatar",
      "typeName": "Gravatar",
      "url": "http://gravatar.com/rdegges",
      "username": "rdegges"
    },
    {
      "bio": "I'm the Chief Hacker @ Telephony Research, where I build telephony tools for developers using cool technologies.",
      "followers": 0,
      "following": 0,
      "id": "105723327194710521939",
      "type": "googleplus",
      "typeId": "googleplus",
      "typeName": "Google Plus",
      "url": "https://plus.google.com/105723327194710521939"
    },
    {
      "id": "85568398087900609",
      "type": "klout",
      "typeId": "klout",
      "typeName": "Klout",
      "url": "http://www.klout.com/user/rdegges",
      "username": "rdegges"
    },
    {
      "bio": "I'm just a happy programmer that likes to hack stuff.",
      "followers": 1623,
      "following": 1158,
      "id": "28896389",
      "type": "twitter",
      "typeId": "twitter",
      "typeName": "Twitter",
      "url": "http://www.twitter.com/rdegges",
      "username": "rdegges"
    },
    {
      "bio": "Developer Evangelist at Stormpath",
      "type": "linkedin",
      "typeId": "linkedin",
      "typeName": "LinkedIn",
      "url": "https://www.linkedin.com/pub/randall-degges/8b/34a/132"
    },
    {
      "type": "flickr",
      "typeId": "flickr",
      "typeName": "Flickr",
      "url": "http://www.flickr.com/photos/rdegges",
      "username": "rdegges"
    },
    {
      "bio": "I'm a happy programmer who enjoys using python, django, c, asterisk, freeswitch, opensips, and telephony to build fun, efficient, and awesome apps.",
      "type": "aboutme",
      "typeId": "aboutme",
      "typeName": "About.me",
      "url": "http://about.me/rdegges"
    },
    {
      "followers": 124,
      "following": 124,
      "id": "6717855",
      "type": "facebook",
      "typeId": "facebook",
      "typeName": "Facebook",
      "url": "https://www.facebook.com/rdegges",
      "username": "rdegges"
    }
  ]
}

As you can see, enrich was able to grab a LOT of information about me, based solely on my email address!

Enriched Data

By default, enrich will attempt to grab several data points for each user you have:

  • photos
  • contactInfo
  • organizations
  • demographics
  • socialProfiles

Depending on the what’s publicly available, some of these sections may not be available. When I ran a test on our Stormpath employees, I was able to find a lot of information on just about every person here!

Why Enrich Your Users?

Enrich allows you to customize your user experience very easily. Let’s say I wanted to build a very simple SaaS application — using enrich I’d be able to:

  • Register a new user with only an email address and password.
  • Automatically find this user’s avatar, and use it in my interface to help give my dashboard a more personalized feel.
  • Automatically find this user’s first and last name to greet them (“Welcome back, Randall!”).
  • Integrate deographic information like age, gender, and location into my analytics.
  • Figure out what organization this user is associated with (maybe they’re the CEO of a huge company, and you should email them directly!).

Using Enrich

Using enrich is simple.

First, you’ll need to install npm, the Node.js package manager. Once npm is installed, you can then install enrich by running:

1
$ npm install -g stormpath-enrich

Next, you’ll need to have two accounts:

After you’ve created your accounts, and have your API keys, all you have to do to configure enrich is run:

1
$ enrich --configure

And you will be prompted to enter your credentials.

Once that’s done, just run:

1
$ stormpath-enrich

And your user accounts will be automatically enriched!

NOTE: For best results, I recommend running enrich on a cron job periodically, this way you’ll continuously update your user accounts with the latest available information.

Thoughts, Feedback?

If you’ve got any thoughts or feedback, I’d love to hear it! Please leave a comment below, or drop me a line.


Viewing all articles
Browse latest Browse all 278

Trending Articles