Name: medium-sdk-python
Owner: Medium
Description: Python SDK for Medium's OAuth2 API
Created: 2015-10-01 20:45:29.0
Updated: 2018-01-07 13:35:07.0
Pushed: 2016-08-09 20:46:36.0
Homepage: null
Size: 22
Language: Python
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
This repository contains the open source SDK for integrating Medium's OAuth2 REST API with your Python app.
For full API documentation, see our developer docs.
To install dependencies using pip:
install -r requirements.txt
medium import Client
to http://medium.com/me/applications to get your application_id and application_secret.
nt = Client(application_id="MY_APPLICATION_ID", application_secret="MY_APPLICATION_SECRET")
ild the URL where you can send the user to obtain an authorization code.
_url = client.get_authorization_url("secretstate", "https://yoursite.com/callback/medium",
["basicProfile", "publishPost"])
end the user to the authorization URL to obtain an authorization code.)
change the authorization code for an access token.
= client.exchange_authorization_code("YOUR_AUTHORIZATION_CODE",
"https://yoursite.com/callback/medium")
e access token is automatically set on the client for you after
successful exchange, but if you already have a token, you can set it
rectly.
nt.access_token = auth["access_token"]
t profile details of the user identified by the access token.
= client.get_current_user()
eate a draft post.
= client.create_post(user_id=user["id"], title="Title", content="<h2>Title</h2><p>Content</p>",
content_format="html", publish_status="draft")
en your access token expires, use the refresh token to get a new one.
nt.exchange_refresh_token(auth["refresh_token"])
nfirm everything went ok. post["url"] has the location of the created post.
t "My new post!", post["url"]
To run tests against this package, first install the test requirements and make
sure that the medium
package is exportable. (We recommend using virtualenv.)
p install -r tests/requirements.txt
p install -e .
Then run the primary test file:
thon tests/test.py
Questions, comments, bug reports, and pull requests are all welcomed. If you haven't contributed to a Medium project before please head over to the Open Source Project and fill out an OCLA (it should be pretty painless).
Copyright 2015 A Medium Corporation
Licensed under Apache License Version 2.0. Details in the attached LICENSE file.