Giter Site home page Giter Site logo

medium-sdk-nodejs's Introduction

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-sdk-nodejs's People

Contributors

futur avatar kylehg avatar kylewm avatar majelbstoat avatar mikkot avatar yoshyosh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

medium-sdk-nodejs's Issues

The NPM module need to be updated

image

VS what is in NPM

image

The payload.data was causing errors to be thrown because explanation #8. This was causing some headaches until I decided to check git and it was fixed. An update to NPM is needed.

Unlimited Claps - general issue

Raising this issue here, because i coudn't find anywhere else to report.
There's no way to "unclap" on an article. Everytime I clap on an article, the tally increments by 1. See the image below:
image
I really don't remember having unlimited clap feature before, so thought to bring it your attention.
Cheers

Readme.md provides wrong information

According to Readme file, we need to run npm install medium-sdk-nodejs and then var medium = require('medium-sdk-nodejs').

Both of them don't work and correct usage is npm install medium-sdk and then var medium = require('medium-sdk').

Not giving a pull request because it'll take time to register.

_makeRequest calls back undefined

At line 275 callback(null, payload.data) actually calls back (null, undefined), which causes a TypeError later when trying to get the access_token.

May be conflicting with body-parser - my payload is the actual data already. Changing this to callback(null, payload) has the expected behaviour.

Medium Analytics

Hi Team,

Is there a way to retrieve analytics from medium publications?

Our intent is to add to our internal analytics.

Thanks

data.accessToken should be data.access_token

at line 231, in "this._accessToken = data.accessToken" data.accessToken is undefined. Changing it to data.access_token fixes it.

The JSON response returned contains the key "access_token" and not "accessToken"

All User Publications Not Returned

I am hitting https://api.medium.com/v1/users/{userId}/publications through the NodeJS SDK for this api and only getting back 17 of the 35 publications that I am associated with. Most importantly, the api isn't returning all the publications I own or edit. I have pasted the response below.

It also returns publications I no longer have any relationship with: "Inspire the World" is one such publication. An example of one of my publications that are missing is "The Vegan"

[
   {
      "id":"15f753907972",
      "name":"3 min read",
      "description":"The official Medium blog",
      "url":"https://medium.com/blog",
      "imageUrl":"https://cdn-images-1.medium.com/fit/c/400/400/1*nx4UstHiCe6kAI_25QmvMA.png"
   },
   {
      "id":"2817475205d3",
      "name":"Medium Engineering",
      "description":"Stories from the team who are building Medium.",
      "url":"https://medium.com/medium-eng",
      "imageUrl":"https://cdn-images-1.medium.com/fit/c/400/400/1*rPOoYCvFQDKxxjP-ByrH7g.png"
   },
   {
      "id":"2bb9dfffef3a",
      "name":"Visual Snow",
      "description":"Our hallucinations are no longer the same. Tell your story and together we’ll approach a cure.",
      "url":"https://medium.com/visual-snow",
      "imageUrl":"https://cdn-images-1.medium.com/fit/c/400/400/1*5YPmjtEB_ueDR-5Us9zWyA.jpeg"
   },
   {
      "id":"2e5ce7f173a5",
      "name":"Google Developers",
      "description":"Engineering and technology articles for developers, written and curated by Googlers. The views expressed are those of the authors and don’t necessarily reflect those of Google.",
      "url":"https://medium.com/google-developers",
      "imageUrl":"https://cdn-images-1.medium.com/fit/c/400/400/1*YPxqkb8PlWYBtLLJiPWNbg.png"
   },
   {
      "id":"301f4089ab9d",
      "name":"On Fashion",
      "description":"Everything Fashion",
      "url":"https://medium.com/on-fashion",
      "imageUrl":"https://cdn-images-1.medium.com/fit/c/400/400/1*p0ctV6KKQZJPEH1_tRQgEg.png"
   },
   {
      "id":"323c513f6364",
      "name":"Be Yourself",
      "description":"Don't instruct, share.",
      "url":"https://medium.com/life-tips",
      "imageUrl":"https://cdn-images-1.medium.com/fit/c/400/400/1*fQU81iavBgiWfXZNvBtnDQ.png"
   },
   {
      "id":"336d898217ee",
      "name":"freeCodeCamp",
      "description":"Our community publishes stories worth reading on development, design, and data science.",
      "url":"https://medium.com/free-code-camp",
      "imageUrl":"https://cdn-images-1.medium.com/fit/c/400/400/1*MotlWcSa2n6FrOx3ul89kw.png"
   },
   {
      "id":"341417f8ba77",
      "name":"Inspire the World",
      "description":"Inspire the world one story at a time.",
      "url":"https://medium.com/inspire-the-world",
      "imageUrl":"https://cdn-images-1.medium.com/fit/c/400/400/1*EM_amaHSeG_3Pxh3Tb6xOQ.jpeg"
   },
   {
      "id":"37bffeb025cd",
      "name":"Jean Hsu",
      "description":"Jean is an engineering leadership coach who is passionate about sharing her people-centric leadership style with teams from small startups to larger companies",
      "url":"https://medium.com/jean-hsu",
      "imageUrl":"https://cdn-images-1.medium.com/fit/c/400/400/1*WmLJMJRwer_d0q_T2NkbtA.png"
   },
   {
      "id":"39d9b4950757",
      "name":"Marketing And Growth Hacking",
      "description":"Everything Marketing and Growth Hacking.",
      "url":"https://medium.com/marketing-102",
      "imageUrl":"https://cdn-images-1.medium.com/fit/c/400/400/1*PlzjoMmo-8hyhpHaPNmmXA.png"
   },
   {
      "id":"3a8144eabfe3",
      "name":"Hacker Noon",
      "description":"how hackers start their afternoons.",
      "url":"https://medium.com/hacker-daily",
      "imageUrl":"https://cdn-images-1.medium.com/fit/c/400/400/1*76XiKOa05Yya6_CdYX8pVg.jpeg"
   },
   {
      "id":"3fbda34dbc32",
      "name":"Growth Hackers",
      "description":"The official Medium account of http://GrowthHackers.com. Premiere destination to collaborate and get inspired to help grow your business.",
      "url":"https://medium.com/growthhackers",
      "imageUrl":"https://cdn-images-1.medium.com/fit/c/400/400/1*Cgtx6FUvotilpFzusYkB2w.png"
   },
   {
      "id":"431752823a68",
      "name":"Y Combinator",
      "description":"Make something people want. See all our posts @ blog.ycombinator.com",
      "url":"https://medium.com/ycombinator",
      "imageUrl":"https://cdn-images-1.medium.com/fit/c/400/400/1*92PO1Xhdb7d-OWMfdNvPug.png"
   },
   {
      "id":"46d7368244ce",
      "name":"Statement",
      "description":"Building a better way to express yourself fashionably and influence your world.",
      "url":"https://medium.com/statement",
      "imageUrl":"https://cdn-images-1.medium.com/fit/c/400/400/1*p0ctV6KKQZJPEH1_tRQgEg.png"
   },
   {
      "id":"5d3d6e983893",
      "name":"Couple’s Reviews",
      "description":"Reviews by a unique couple",
      "url":"https://medium.com/couples-reviews",
      "imageUrl":"https://cdn-images-1.medium.com/fit/c/400/400/1*PuMIHBx8diaIrQAjFhFiqA.png"
   },
   {
      "id":"5e53b8da3c5f",
      "name":"A Couple Reviews",
      "description":"A Couple Fun Reviews of the World by a Unique Couple. Fun reviews of anything a couple might use from the newest tech gadgets to vegan food.",
      "url":"https://medium.com/a-couple-reviews",
      "imageUrl":"https://cdn-images-1.medium.com/fit/c/400/400/1*mO2aamcKAB2jDsnX0Of4vQ.png"
   },
   {
      "id":"5f96c2d877c4",
      "name":"How We Get To Next",
      "description":"Inspiring stories about the people and places building our future. Created by Steven Johnson, edited by Ian Steadman, Duncan Geere, Anjali Ramachandran, and Elizabeth Minkel. Supported by the Gates Foundation.",
      "url":"https://medium.com/how-we-get-to-next",
      "imageUrl":"https://cdn-images-1.medium.com/fit/c/400/400/1*Qbl-AvxrT0FL4FFCGaHDUw.png"
   }
]

List Posts method missing?

I see a lot of useful methods in the API, but I don't find any method to list all my actual Posts, or all the posts from within a publication. Is this intentional?

Thought it would be something really obvious to exist in the API. Or am I missing something?

API Error: User not found!

Medium API doesn't work.
I have created an APP and authorized my user. Fetched the access_token successfully.
But when I try to fetch an authorized user's info, I have gotten the below error message:
{"errors":[{"message":"User not found","code":6004}]}

These are the logs:
http://prntscr.com/qarjrp
http://prntscr.com/qark4h

I have tried to create a new "Integration tokens" from my User settings and tried to use it instead of the access token. But the same result. I can not get authorized user's information.
What is wrong? Could you help me, please?
I have contacted the Medium support team several times. But their support is very bad. They reply very late and every time writes unrelated messages.

Thanks in advance.

npm fails

'medium-sdk-nodejs' is not in the npm registry.

Is there an any endpoint that changes ownership of the article?

I am building a dApp and I need to a REST endpoint which can change the ownership of any article on medium.
This essentially means that any revenue generated after changing the ownership will be claimable by the new owner.
This is a simple usecase for an ERC721 token where authors can trade ownership/rights of any article. Is this something that dev API supports?

Can't get Access Token

I have tried to use the SDK as well as do it myself, but no luck...

Attempt 1

var client = new medium.MediumClient({
  clientId: '132d940695be',
  clientSecret: 'af9aa97aa69364beb36225b79b231c882e537ca1'
});


var url = client.getAuthorizationUrl('secretState', 'https://q-apps.io/api/medium', [
  medium.Scope.BASIC_PROFILE, medium.Scope.PUBLISH_POST
]);

console.log(url);

this is how i am trying to get access token

client.exchangeAuthorizationCode('f79dd700c137', 'https://q-apps.io/api/medium', function (err, token) {
  console.log(err);
  console.log(token);
 });

but i get the following

{ errors: [ { message: 'Authorization code not found.', code: 6016 } ] }

I am testing this on localhost, I don't know why this is not working.

How do you post images?

I didn't see anything in the readme. Do you just post images using regular html and the src tag? Where the src = some-external-link.png?

What is the status of using api sdk?

Hello,

Before I was using medium sdk as the following:

const client = new sdk.MediumClient({ clientId: INPUT_APP_ID, clientSecret: INPUT_APP_SECRET });
client.setAccessToken(INPUT_ACCESS_TOKEN);

await client.createPost(...);

As I understand for now applications are deprecated.

Support reply:

We don't allow any new integrations with our API.

The Medium API is only available for an integration token for use with third-party writing applications, such as:

    iA Writer
    Ulysses

It's still required to pass app_id, app_secret when creating an SDK client:

function MediumClient(options) {
  this._enforce(options, ['clientId', 'clientSecret'])

Can you clarify, how can we use this SDK based just on personal access token?

API error 6005: Application not found

Hi,
I'm trying to use your API with the Integration Token generated on my settings and I'm getting this response:
{ "errors": [ { "message": "Application not found", "code": 6005 } ] }

This is my request:

GET /v1/me HTTP/1.1
Host: api.medium.com
Content-Type: application/json
Accept: application/json
Accept-Charset: utf-8
Authorization: Bearer

Am I doing something wrong?
By now I am testing it in Postman, then I will use it from my Angular App.
Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.