Viticci published a wonderful reencounter with 1Writer this week on MacStories while, by sheer coincidence, I was working on this action for a colleague to plug 1Writer into Medium with their fresh API. This article will guide you through a couple of steps to get it working.
Your first task is to generate an integration token, a secret key the script will use to connect into your Medium account. Log into your Medium account, go to Settings and scroll until you find a section titled Integration Tokens, set a description and click the Get integration token button, you’ll get your key below, a long string of random characters.
Avoid sharing your API token since anyone can publish into your account with it. In case you share your API token, revoke and create a new one.
Setting up the action
I’ll give you two ways to build your Post to Medium action:
- The Easy Way: follow a step by step guide on Workflow and create a 1Writer action with the code it outputs;
The Easy Way
Set a name, pick an icon, paste your code in the script field and you’re good to go.
The Hard Way
data variable. It holds all the configurations we’ll send to Medium later. This is how you can set each of them:
title: leave it as empty string. The script will ignore anything you put here.
contentFormat: accepts 2 strings:
"html". You can also set as boolean,
false, to be prompted before publishing.
content: grabs text from the editor, I wouldn’t play with this one if I were you.
publishStatus: Would you prefer your post to be public, a draft or unlisted? This is where you decide that. You can either set the value as a string or true to be asked before publishing.
license: The license of your piece. You can check all the licenses available here. Again, set to
trueto be asked before publishing.
tags: takes a comma-separated string, an array or
true. The latter to be asked before publishing. Default is an empty array.
canonicalUrl: this is a reference url when you write someplace else and publish on medium. Set it to
trueto be asked for a url before publishing.
After you configure the
data, look for this line:
var token = '', usrId = '', headers;
token to the integration token we got in the beginning of this article. Now we need your user ID. The action will get the user ID for you every time you publish in case you leave it blank, otherwise you can create an url to find out:
yourtoken with your integration token and open that url in Safari, you'll receive a JSON object. You want the value from
data.id, a long random string just like your token.
I hope this workflow eases your Medium workflow on iOS. If you face any errors or bugs, it's dangerous to go alone. Take this and let me know of the issue so we can work it out together.