medium-sdk-nodejs

A NodeJS SDK for Medium's OAuth2 API https://medium.com

  • Owner: Medium/medium-sdk-nodejs
  • Platform:
  • License:: Apache License 2.0
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

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's OAuth2 API into your NodeJs app.

View the full documentation here.

Install

npm install medium-sdk

Usage

Create a client, then call commands on it.

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: '<h1>A New Post</h1><p>This is my new post.</p>',
      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 and fill out an OCLA (it should be pretty painless).

Authors

Jamie Talbot

License

Copyright 2015 A Medium Corporation

Licensed under Apache License Version 2.0. Details in the attached LICENSE
file.

Main metrics

Overview
Name With OwnerMedium/medium-sdk-nodejs
Primary LanguageJavaScript
Program languageJavaScript (Language Count: 1)
Platform
License:Apache License 2.0
所有者活动
Created At2015-10-07 20:16:22
Pushed At2024-02-25 18:35:53
Last Commit At2018-10-10 19:50:34
Release Count0
用户参与
Stargazers Count348
Watchers Count112
Fork Count34
Commits Count38
Has Issues Enabled
Issues Count20
Issue Open Count6
Pull Requests Count15
Pull Requests Open Count4
Pull Requests Close Count1
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private