medium-sdk-nodejs

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

  • 所有者: Medium/medium-sdk-nodejs
  • 平台:
  • 许可证: Apache License 2.0
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

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.

主要指标

概览
名称与所有者Medium/medium-sdk-nodejs
主编程语言JavaScript
编程语言JavaScript (语言数: 1)
平台
许可证Apache License 2.0
所有者活动
创建于2015-10-07 20:16:22
推送于2024-02-25 18:35:53
最后一次提交2018-10-10 19:50:34
发布数0
用户参与
星数348
关注者数112
派生数34
提交数38
已启用问题?
问题数20
打开的问题数6
拉请求数15
打开的拉请求数4
关闭的拉请求数1
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?