So, a few months ago, Flickr decided to change their terms and conditions so that they could sell your Creative Commons photos. This got a lot of people’s goat, myself included since I’m a paid user, and have been for a while (as an aside, had Yahoo done it as a profit share, it would have been awesome for everybody, but noooo…)

Because self hosting in this post Snowden world is only ever going to be a good thing, I don’t want my family photos used in corporate branding without a cut, and because I wanted to be a good #indieweb citizen, I thought I’d take the plunge and move to self hosting.

I’ve tried this before with Trovebox Community Edition but didn’t have much success – while their Flickr data export seemed to work, the import didn’t. They’ve probably got it working by now, but I pretty much gave up.

Anyway, since I’m a contributor to Known, I thought I’d dogfood and hack together an importer.

Flickr Importer for Known

The importer works by calling the Flickr API using credentials stored in your linked Flickr account. To do this, it uses the Flickr syndication plugin to do the donkey work of linking your accounts.

Once activated, and your Flickr account is linked, you are given the option to run an import.

The import job will run in the background, and will import all your photos and videos into your photostream (using the Photo and Media plugins which should also be activated), preserving timestamps, titles, body and tags.

At the time of writing I’ve not got it importing photosets and collections, since Known currently lacks a logical mapping, but I’m keen to at least record this information for later processing. The script will import sets and collections as generic data items, which you can expose by writing support into your theme.

The plugin records state, so it should recover from crashes, and you can re-sync safely at any time.

Have a play and let me know what you think! Pull requests are of course welcome.

» Visit the project on Github...

So, here’s a plugin that implements a basic Known to Known cross poster, which uses the Known API authenticated with OAuth2 using my OAuth2 server.

This post will let you link an account on one Known server with an account on another Known server, and allow you to crosspost status and text posts from one to the other.

Primarily this is a demo of OAuth together with the Known API, but it might be handy if you have, say, a corporate blog but still want to post to it from your main site.

Pull it apart, play with the OAuth and see how I talk to the API!

» Visit the project on Github...

OAuth is a technology that allows a user to connect a client to a service, but without that user needing to enter their password.

The usual way this works is that a user clicks on a button, and are taken to a page asking whether they wish to allow the connection. Under the bonnet a handshake is going on between the client and server, resulting in an exchange of tokens.

If you’ve ever used the “Facebook connect” or “Sign in with twitter” buttons, you are likely familiar with this.

Known has a comprehensive API, and while it is possible to authenticate yourself to it using signed HTTP headers, I thought it’d be handy to be able to authenticate with OAuth as well (it was an excuse for me to write the code powering the server side of an OAuth exchange, a good way to understand it!).

The plugin I wrote lets a user manage “applications” – collections of keys – which can be used by an OAuth2 client to power an exchange.

Example Usage

Here is an example of client authentication in it’s most basic…

To get a code:

https://mysite.com/oauth2/authorise/?response_type=code&client_id=<your API Key>&redirect_uri=<path to your endpoint>

You will be directed to a log in page, followed by a confirmation page as necessary, after which you will get a response code back. This response will either be a JSON encoded blob, or if you specified a redirect_uri, the values will be forwarded as get variables.

Exchanging the code for a token

https://mysite.com/oauth2/access_token/?grant_type=authorization_code&client_id=<your API Key>&redirect_uri=<path to your endpoint>

You should get back a json encoded blob with an access token, expiry and refresh token.

Once you’ve performed an OAuth exchange, you will be provided with an access token. You can pass this token along with any web service API call to authenticate your request.

» Visit the project on Github...