Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Medium/medium-sdk-nodejs
A NodeJS SDK for Medium's OAuth2 API https://medium.com
https://github.com/Medium/medium-sdk-nodejs
Last synced: 5 days ago
JSON representation
A NodeJS SDK for Medium's OAuth2 API https://medium.com
- Host: GitHub
- URL: https://github.com/Medium/medium-sdk-nodejs
- Owner: Medium
- License: apache-2.0
- Created: 2015-10-07T20:16:22.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2024-02-25T18:35:53.000Z (9 months ago)
- Last Synced: 2024-10-25T22:50:28.428Z (17 days ago)
- Language: JavaScript
- Size: 22.5 KB
- Stars: 345
- Watchers: 112
- Forks: 33
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
**Warning:** This sdk is no longer supported or maintained by Medium.
# Medium SDK for NodeJS
This repository contains the open source SDK for integrating [Medium](https://medium.com)'s OAuth2 API into your NodeJs app.
View the full [documentation here](https://github.com/Medium/medium-api-docs).
Install
-------npm install medium-sdk
Usage
-----Create a client, then call commands on it.
```javascript
var medium = require('medium-sdk')var client = new medium.MediumClient({
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET'
})var redirectURL = 'https://yoursite.com/callback/medium';
var url = client.getAuthorizationUrl('secretState', redirectURL, [
medium.Scope.BASIC_PROFILE, medium.Scope.PUBLISH_POST
])// (Send the user to the authorization URL to obtain an authorization code.)
client.exchangeAuthorizationCode('YOUR_AUTHORIZATION_CODE', redirectURL, function (err, token) {
client.getUser(function (err, user) {
client.createPost({
userId: user.id,
title: 'A new post',
contentFormat: medium.PostContentFormat.HTML,
content: 'A New Post
This is my new post.
',
publishStatus: medium.PostPublishStatus.DRAFT
}, function (err, post) {
console.log(token, user, post)
})
})
})
```Contributing
------------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](https://github.com/Medium/opensource#note-to-external-contributors) and fill out an OCLA (it should be pretty painless).
Authors
-------[Jamie Talbot](https://github.com/majelbstoat)
License
-------Copyright 2015 [A Medium Corporation](https://medium.com)
Licensed under Apache License Version 2.0. Details in the attached LICENSE
file.