Connecting WordPress to OpenStreetMap with Auth0

If you log in to this blog you can now do so using your OSM account. If I say so myself, that’s pretty awesome. Here’s how I did it:

First we need to install the Auth0 WordPress Plugin which you can find by opening up WP, going to plugins and searching for “Auth0.”

Auth0 is just fantastically awesome. It’s a service which allows you to login to anything using anything. For example, you have a rails project and want to log in using facebook. Or you have a Node project and you want to log in using Active Directory. Or in our case, WordPress and log in using OSM. Auth0 is very extensible and developer friendly. For example, there are arbitrary JS events that fire through the login process. You can have twilio send you an SMS when someone logs in as an example.

Another way I like to think about it is like this: It used to be that you’d write a PHP app with JS front end and SQL backend. What Ruby on Rails did is meld together SQL and Ruby so now you only need to learn two things (Ruby and JS). You didn’t have to write SQL as well. Now things like meteor are removing even that so you just write JS everywhere. In a similar way – the first thing you do when you make an app is usually go build your login system. No more! Just use Auth0 and avoid all that pain. Auth0 is going to be more secure than anything you do, and immediately extensible.

Once you’ve installed your WP plugin, head over to the connection API Explorer.  Most things in your Auth0 dashboard are trivial you just turn them on and off like this:Capture

But OSMs authentication API isn’t this easy for a number of reasons. First, it uses OAuth 1.0(a) and Auth0 support version 2 out of the box as a thing on the dashboard. Second, OSM still uses XML where the rest of the world has moved on to JSON.

But it still works! We just need to use the Auth0 connection API to create a connection.

Next you need to log in to OSM. Click on your user at the top right, click settings, click OAuth settings, and create a OAuth Client. More docs are here. Once you have a OAuth app set up on OSM, you will get your client id and secret you can use with the code below.

On the Auth0 dashboard, create an application (applications -> create) and note down the client ID and secret.

On the API page, create a token with connections:create with the token generator at the top left – this lets you create new connections straight from the browser:

Capture2You also want to create a token with all the permissions around the following: clients (create and update), connections (create, read and update), rules (create and delete) and users (create, read and update). Note down this token, as the Auth0 WP plugin will need it.

Next we need to paste some code in to the box marked “body”:

{
  "name": "OpenStreetMap",
  "strategy": "oauth1",
  "options": {
    "client_id": "YOUR OSM CLIENT ID HERE",
    "client_secret": "YOUR OSM SECRET HERE",
    "requestTokenURL": "https://www.openstreetmap.org/oauth/request_token",
    "accessTokenURL": "https://www.openstreetmap.org/oauth/access_token",
    "userAuthorizationURL": "https://www.openstreetmap.org/oauth/authorize",
    "scripts": {
      "fetchUserProfile": "function (token, tokenSecret, ctx, cb) {var parseString = require('xml2js').parseString;var OAuth = new require('oauth').OAuth;var oauth = new OAuth(ctx.requestTokenURL,ctx.accessTokenURL,ctx.client_id,ctx.client_secret,'1.0',null,'HMAC-SHA1');oauth.get('http://api.openstreetmap.org/api/0.6/user/details',token,tokenSecret,function(e, b, r) {if (e) return cb(e);if (r.statusCode !== 200) return cb(new Error('StatusCode: ' + r.statusCode));parseString(b, function (err, result) {if (err) return cb(err);var profile = {user_id: result.osm.user[0]['$']['id'],given_name: result.osm.user[0]['$']['display_name'],picture: result.osm.user[0].img[0]['$'].href};cb(null, profile);});});}"
    }
   },
"enabled_clients": [
    "AUTH0 APPLICATION CLIENT ID HERE"
  ]
}

Remember to enter your ID and secret. Now click the “Try” button and you should get a “201” response that the connection was created.

So now we need to hook this up to the Auth0 login box (called the “lock”). Back on your wordpress site, go to the Auth0 plugin, settings, basic. Here enter your client ID and secret from when you made the application in the Auth0 dashboard. Also add the API token you created with all those permissions and click save. Next go to the advanced settings and enter the following in the CSS box:

#a0-lock.a0-theme-default .a0-zocial.a0-osm {
    color: #fff;
    width: 40px;
    height: 40px;
    background: #ffffff url('http://www.openstreetmap.org/favicon.ico') center center no-repeat no-repeat;
    background-size: 21px;
    border: 1px solid #5C666F;
}

And then this in the JS box:

lock.once('signin ready', function() {
    var link = jQuery('<div title="Login with Open Streen Maps" class="a0-zocial a0-icon a0-osm " dir="ltr"><span>Login with Open Streen Maps</span></div>');
    link.on('click', function () {
        lock.getClient().login({
            connection: 'OpenStreetMap' });
    });

    var iconList = jQuery('.a0-iconlist');
    iconList.append(link);
});

We need to do this to add the button on the login box for OSM. Lastly, go back to your Auth0 dashboard and the app you created. You’ll need to add a line in “Allowed Callback URLs ” which will be unique for your site, but for my blog it’s this: http://stevecoast.com/index.php?auth0=1

That should be it, now users can log in using OSM:

Capture3Notice that I’ve turned on facebook, GitHub and so on… and a the end there’s the OSM logo. Click it and you can login with OSM!

Of course, now you’ve done this it means you can connect an iOS application, your webapp or anything else to OSM in the same way. Magic.

0

Why I like what3words

When I first came across w3w I had the same reaction many people do – I just didn’t get it.

The idea is pretty simple. Give every 9ft square on the planet three words. So right now I’m at spite.nearly.maps which is a hotel next to SFO. Or hills.boost.oldest is somewhere in England.

There are people out there for whom location is a daily problem. Firefighters trying to find a hydrant. Police trying to find one another. Delivery drivers trying to find the right door. The billions of people who don’t have an address system. For people like that, having some kind of location system makes obvious sense. It’s not hard to help them understand the value of w3w since they spend half their life looking for “the green door half way down on the left.” At 3am. In an emergency.

For most other people we only have this problem occasionally. First you live somewhere where there are addresses. Second you have a phone. But you still have situations where your friend can’t find you in a crowd. Or you go to the doctor and their address is on A Street but the entrance is on 1st Avenue. It doesn’t happen that often so you don’t think of it as a big deal.

But it actually is. If you multiply out all that wasted energy it’s going to end up as billions of dollars of wasted time and gasoline. Just think of every time the secretary has to explain to the new patient that the entrance is on a different street, every day for years. In just one doctors office.

Then in the mapping world, and the computer world, we think this is easy. It’s just latitude and longitude. Or at worst, it’s just a geohash. This is true whenever you have two computers talking about location. If we both have phones, then they can just swap location data off the GPS. Yay.

But here’s the thing. First – where humans are involved you want something simpler. And second geohashes are terrible for actual location when a human needs it.

Geohashes and lat/longs have a bunch of downsides for humans. They’re difficult to remember, bordering impossible. They’re ambiguous – if you get a number wrong then there’s no way to check. And of course everyone has their own hash system.

If you want to design a system that anyone can use and remember, three words is actually a pretty good solution.

  • You can remember three words
    • Shorter words are used near population centers to help this
    • Homonyms are removed (sail, sale)
    • Negative words are removed
  • There’s built in error correction
    • Similar sets of words (e.g. spite.nearly.maps and spit.nearly.maps) are in very different places, so it’s clear there is a problem
  • You can say it over a phone or radio
    • No “b like banana” to spell some strange code out
  • It doesn’t take a lot of cognitive function
    • It’s just three words, not some complicated looking thing that I might mistake a 1 for a 7 or something

If you look at the hashes that have existed in the past they tend to be some code for location like ‘dy32gE@3’. The technologist solution to this problem is “make an algorithm, make it open, we’re done!”

But the value is much less in just making any old algorithm and declaring the problem solved. The actual value here is first, to build a great algorithm for people, not just for PhDs in Mathematics. Second, to market it.

Because that’s where everyone kind of just gave up. There’s this fantasy that if I make something open and put it on the internet that somehow, via magic, people will use and build upon it. But people don’t. Mostly they don’t know it exists, don’t know it’s a problem and will never use your random geo hash thing.

The thing that’s useful and interesting here with w3w is that a lot of thought and time is going in to marketing and PR so people know about the problem and the solution. And if you go look, that is getting a lot of traction all over the place. Because it turns out that everyone from camping magazines to Glastonbury festival staff to people delivering mail in slums needs a location service. And they’re using w3w.

Even Ireland could do with something better than spending 27 million Euro on a code system.

To drill it home; it’s not the technology. The technology is great, and a lot of work goes in to that. Actual real linguists work on building new language versions. Other hashing algorithms I’m sure were great in their way too. But who cares if nobody uses them?

And that’s why w3w is interesting. They have truly great – some of the best I’ve seen – people who’re pushing this solution all over the place to people for whom it’s an actual problem. If you live in a western country with addresses, a functional cell phone network and you work on open mapping… that probably just isn’t you.

The other thing is, it’s a company born of a problem which means there’s a focus. It isn’t about just burning more money and figuring out what business model fad to follow this week. It’s a real problem, experienced and solved by the same people. Chris, one of the co-founders, actually had this problem coordinating deliveries of music equipment and performers to perform live events. He couldn’t get multiple trucks to show up in the same place. Even when talking to them on the phone. This is in England – a relatively developed country with a paved road network, where citizens speak a common language and road signs blanket the country. Where people are highly paid and educated.

And for some reason we consider it normal in such a modern time and place, that two people can’t locate each other occasionally. That’s actually nuts when you think about it. It’s 2016 – really this should not be a problem. And it costs us a lot of time, energy and money.

By contrast imagine you were born in a world where w3w just existed and everyone used it. You’d think your grandparents were pretty dumb to not be able to find each other at a concert. Or not be able to tell an emergency responder where you were in a field or on a big road. Or that delivery drivers actually wandered around trying to find the right door. And yet were able to somehow land rockets on the moon.

Because that’s the world we live in. And maybe by building a common language of location, for humans, we can make it a problem our grandchildren can just laugh at.

Surface Phone

Six months ago or so I had a job that required a large amount of parallel processing in Windows. The economics and technical constraints of it were such that doing it in the cloud wasn’t going to work easily. So I took to craigslist and bought 8 laptops for about $50-100 each and put Windows 10 preview on them.

These were crappy, old, low spec laptops with keyboards that mostly functioned. And here’s the thing: Win10 ran great on them. Surprisingly great. I hooked them all up to wifi and a remote disk, ran a command and they were off and computing stuff for me. Then I sold them all again, for basically what I paid for them.

Microsoft is rumored to be working on a flagship phone device, dubbed the Surface Phone.

continuum_windows_10_mobile-Large

Begin pure speculation:

I think the Surface Phone is just going to run full Windows 10 and it’ll be an x86/64 Intel device. Here’s why:

  • Windows 10 Mobile on high end devices now feature Continuum. You plug in a display and keyboard and mouse (or bluetooth) and it becomes a pseudo-desktop computer. I say pseudo because the apps are still the pretend Office, pretend Outlook and so on. A real Win10 phone will just be a real Win10 computer. Plug in the display, and it’s a real machine, able to run the universe of windows apps.
  • Old hardware runs Win10 great, as I discovered. Phones are really just old hardware.
  • The high end Lumias can apparently accept micro-SD cards up to 2Tb. I put a 1 or 2Tb SD card in my Surface Phone and it’s a real machine.
  • It fits with the Surface being a tablet-laptop. The Surface Phone can be a phone-desktop.
  • It’ll cut the budgets for enterprise. Microsoft can go to United Airlines, or whatever, and sell them a million phones which are also desktops, cutting the device budget in half. And their IT staff will be happy, since it’s all just still Win10 machines out there.
  • It explains Win10 Mobiles lack of push, and nothing much happening in the phone space for Microsoft. I have it on a Lumia 535, which is a super low end device. It actually works pretty well but it doesn’t feel like Microsoft is super serious about it. The releases are slow and it doesn’t have a ton of polish. Maybe it’s just like WinPhone7 (based on CE) and it’s another stopgap until phones just run the full Win10.
  • It also leverages all the apps. The mobile Outlook and so on can all still run on a x64 Surface Phone.
  • It leverages all of Microsofts strengths. The other 80,000 (or whatever) people at Microsoft can all help the phone be a success if it’s running full Windows. A lot harder if it’s some bastard child requiring special care and attention.
  • Intel is rumored to be working on the Surface Phone too.
  • Because it’s a desktop machine, it’ll be plugged in most of the day. So you can sidestep a lot of power constraints of running a x64 machine all day long on battery.
  • Microsoft has bridge projects so you can port your android or iOS app to Windows. Having a phone just run full Win10 will help immeasurably in simplifying that whole idea. No porting to strange OS or processor. It’s just Windows.
  • What the hell else will they do? Win10 Mobile is going to be tough to push otherwise.
  • It fits the history and it’s just logical. DOS and Win3.1 combined to Win95. 95+NT to become Windows… Pulling in the train of WinPhone OS in to Windows makes sense.
  • Look at the Win10 tablet devices. Stick a SIM card in one and make it slightly smaller and it’s a phone.
  • It has to happen eventually, why not now?

So in short, what you’re seeing in high end Win10 Mobile devices, things like Continuum and porting Android apps over is just  dress rehearsal for phones running full Windows.

In addition to the prediction that it would be a real Win10 machine;

  • I think it’ll be a phablet. It’s the preferred form factor these days and it allows you to fit a bunch of hardware in too. Call it $699 or so and you need to add the SD card. Probably too hard to get the cost down to $499 but you never know.
  • There might be a retail SKU which includes the phone, a dock, keyboard and mouse for $999. Probably just USB for cost reasons.
  • You still want to make the phone able to make phone calls while it’s a desktop computer. This is tough because it means you can’t really use a drop-in dock. You can use a long cable but it’s messy. A dock for power, but the display, keyboard and mouse being wireless would make the most sense but may be too expensive to be viable.
    • Having a SKU for a display with the hub hardware built in would make sense. You pair your phone to the display, which has the keyboard and mouse attached. Rather than having a standard display and separate docking hardware.
  • It might make sense to make some kind of laptop-like dock for the phone, maybe completely wireless again.
  • It might make sense to short desktop hardware makers if all this happens.

Or, maybe I’m completely wrong.

Why you should be using BrowserLocation to get your users location

obl

When a web app asks the browser for location, it prompts the user if they want to share it.

At this point it becomes binary. Either they click ‘yes’ and you get (usually) pretty good latitude and longitude or they hit ‘no’ and you get nothing at all.

The second problem is you just get latitude and longitude. You have to do some work to turn that in to something meaningful like a city or country.

Enter BrowserLocation.

BrowserLocation is a JavaScript wrapper that asks the browser for location. If they click ‘yes’, then we return the data to you just as before but we add city, state and country information. If they click ‘no’ then we fallback to IP address location. This IP-based information is lower accuracy than GPS or wifi triangulation, but better than nothing at all!

And to make it even better, every use of the API is used to improve the IP address fallback data for other users. And you can download the data. And, you can even query it directly like this.

So think of it as an open IP to geo project, with a wonderful API and a virtuous circle where everyone using it also makes the data better. The data is initially released CCBYNC and will leak in to the public domain over time, this creates a space to monetize the data and pay to improve it. It’s been seeded by paying people all around the world to collect some data.

Enjoy. Please email if you have any questions.

Yet Another Todo App

YATA is Yet Another Todo App.

Untitled 1

You start at a high level with all your tasks in a tree of tasks and sub-tasks. If you check one off it gets striked out and will automatically be deleted in 24 hours. You can edit tasks. Here you have the big picture.

Untitled 2

Next, you can look at just the leaves, the things that need to be done at some point. These are the end tasks which have no children. You can highlight important leaves here.

Untitled 3

Last, you can focus on just the leaves that have been highlighted and work on just those today. You can go through, check off those tasks and tomorrow return to the overview to choose what to work on again. This view shows only the things you want to work on, and hides the complexity of everything else that’s going on.

If you want to play with it, YATM is here.

New Year, New Roles

It’s been a wild two-and-a-half years at Telenav helping bring OpenStreetMap to the consumer. We shipped consumer turn-by-turn navigation in the US with Scout which was for me a big first – a turning point of showing OSMs true potential.

As the OSM project at Telenav has grown the need for the visionary founder has shifted and I’m stepping back from full-time work at Telenav. I’ll be still helping part-time and helping with new projects going forward. 2016 is going to be a fun year with a great team at Telenav (including all the bright folks we brought in from Skobbler) and I know they’ll continue to push out more OSM goodness.

The algorithm and the failing kickstarter

I launched a kickstarter yesterday and it’s not doing well.

Here’s my basic algorithm:

  1. Try random things at zero cost
  2. Find the ones that work
  3. Scale those

We really can’t predict what will work or not which is why speed is so important – the more things you try the better since you’ll hopefully find something that will work. Boyd talks about this in his OODA loop. You observe your situation, orient yourself, decide what to do and then act upon it. Then go back to the start. He posits that if you can do this quicker than your opponent then you’ll win.

So let’s observe the situation.  This kickstarter raised about $600 in day one, with a fairly huge amount of publicity amongst map people.

Let’s orient given prior knowledge. The last two kickstarters did $1,600 in day one. They raised just under $15k and $10k total. It’s not super likely this one will reach $5k given the curve and what little we’ve had today (day two).

So it’s decision and action time. I’m pretty sure that:

  1. The prices on the kickstarter are too high
  2. The print images aren’t compelling enough

The prices are easy to drop and simplify. I’m thinking of just having one print at $40 or so since that’s the median price for this kickstarter and the last poster one.

As for the images, I’m working on continent-wide instead of city images. I’ve fixed some of the drawing issues. The thickness of the lines drops as log10() and I’ve changed that to log() which is nicer. I’m also working on aliasing and changing the color from “just black” amongst other things. Here’s an image of all the roads going to london:

foo

There’s a bunch of work to be done here, but it gets the point across. My guess is that continent images like this will be more compelling.

The interesting question is how to get feedback. Asking the existing backers makes partial sense since they committed money but on the other hand, we need to figure out why people who didn’t back it didn’t back it. Feedback welcome of course.

Part of the reason for this whole thing is that the printer I bought for the last project is dead and needs to be replaced. This isn’t compelling in and of itself. Remember the “try random things” part of the algorithm? Well in a sense, yes, random things need to be tried since we can’t predict very well the chance of success. But, there are a couple of things to consider.

If we have two ideas A and B we may as well go for the bigger one. The reason for that is that it has more ways to succeed. A bigger idea may contain some element of a successful idea. A smaller idea has a lower chance of success and a lower overall level of dollars to attract. The cost remains the same: zero. This is because that’s what I’m going to spend since zero means the maximum number of ideas to be tried. Anything above zero restricts the number of ideas.

Second is opportunity cost. Picking the smaller idea costs the potential gain of a bigger idea. Doing a $5k kickstarter is the same as doing a $50k kickstarter with a 10% chance of success. But the $50k idea has a higher potential payoff and the same cost (zero) with a higher number of sub ideas that might spark some following.

There’s also just less competition. Doing anything commercial with OSM right now is hard because there are irrationally funded startups doing everything for free and owning the whole space. Competing with free is hard. At the other end of the spectrum I really love Thing Explainer simply because out of the billion books published this past year, it’s so unique. It’s not another tween vampire romance. Doing unique and big things is the way to go.

Is the cost really zero to do a kickstarter? No. It costs my time and so on, but it’s about as low as you can go.

Back to failure. The typical valley thing is to embrace and love failure. But that’s really just a way of avoiding it the same as treating failure as bad. The secret is to know failure sucks and push through it as a process, not to pretend it’s good or bad. It just is.

I tested a bunch of ideas last year and most of them failed. Nobody remembers any of them. Anyone remember Fake Mayor? That wasn’t even a failure, that sold for actual money. Anyway. I have a bunch of data on the ideas that succeeded and really I should have done one of those as my next kickstarter, or one of the other really big ideas I have laying around. Next time. (And, next time might mean next week at this rate).

(As an aside, I want to do a book about how to test and build ideas for super cheap using the internet, I think it’d be interesting).

So. The plan is to either pivot this kickstarter, kill it or restart it with simplified rewards in the next 24 or 48 hours. What do you think?

(It should be noted that some semi-pivoting by putting the above image on the kickstarter and so on is simple and free so I’ll do that in any case, but it’s not really a full pivot).

Powered by WordPress. Designed by Woo Themes