The aim of this code🎯 is to send a markdown file into Medium. Please note currently this is text-only. The following demo creates test_doc.md
with hello there text and sends it to medium with the script.
- you need the following 3 envirnomental variables
Name | Comment |
---|---|
md2med_TOKEN |
integration token from medium settings |
md2med_USERID |
user id obtained via API call |
md2med_SCRIPT |
path to md2med.py |
cacert |
path to cacert.pem |
- open https://medium.com/me/settings -> Integration tokens -> Get integration token
- create an enviroment variable
md2med_TOKEN
with the value obtained in the step above - open API Testing Tool and populate as follows:
- insert
https://api.medium.com/v1/me
into the address bar - insert integration token into Token field, leave the default selection Bearer Token
- press Send -> obtain the value from id key from the response
- insert
- create an environment variable
md2med_USERID
with the value of id obtained in the step above
- download
cacert.pem
from curl - Extract CA Certs from Mozilla - create an environment variable
cacert
with the value of the path pointing to the cert file - now you are ready to run the script
- navigate to the folder where you have your markdown file you want to publish
- call
md2med.py
ideally via environmental variable so that don't have to copy it to the folder with markdown file with the following parameters:--doc_name
-> random title--file_to_publish
-> file name--tag
->
# no environmental vars
python .\md2med.py --doc_name "hello there!" --file_to_publish "./test_doc.md" --tag "python"
# with environmental var in PowerShell
python $env:md2med_SCRIPT --doc_name "hello there!" --file_to_publish "./test_doc.md" --tag "python"