Coder Social home page Coder Social logo

Comments (8)

codecowboy avatar codecowboy commented on August 22, 2024

Do the params need to be encoded into the web token? If so that won't work for me either. I'd like to connect to the API from the IFTTT Maker channel which doesn't allow manipulation of the Http Headers

from nodebb-plugin-write-api.

julianlam avatar julianlam commented on August 22, 2024

Hi @codecowboy -- the payload values need to be embedded in the web token itself. No manipulation of th HTTP headers is required when using JWT.

from nodebb-plugin-write-api.

codecowboy avatar codecowboy commented on August 22, 2024

@julianlam thanks. I was looking at hitting the API from a webhook which is part of the IFTTT Maker channel. Unfortunately I would need to pass the bearer token as part of the request body as there is no provision for encoding a JWT or setting a header.

From lib/node_modules/passport-http-bearer/strategy.js it looks like you have disabled this option somehow:

  if (req.body && req.body.access_token) {
    if (token) { return this.fail(400); }
    token = req.body.access_token;
  }

  if (req.query && req.query.access_token) {
    if (token) { return this.fail(400); }
    token = req.query.access_token;
  }

  if (!token) { return this.fail(this._challenge()); }

Is that the case? tried altering that code but didn't get anywhere.

from nodebb-plugin-write-api.

julianlam avatar julianlam commented on August 22, 2024

I didn't modify http-bearer (you'll notice it's not in the repo files). You'll need to encode the payload in the actual POST payload or GET querystring parameter.

from nodebb-plugin-write-api.

codecowboy avatar codecowboy commented on August 22, 2024

Hmmm, I am confused then. I see now that you are pulling in passport-http-bearer as a dependency - apologies.

I guess this comment in that file is just wrong and they took this functionality out:

 * The HTTP Bearer authentication strategy authenticates requests based on
 * a bearer token contained in the `Authorization` header field, `access_token`
 * body parameter, or `access_token` query parameter.

I've tried both access_token in the query string and the post body and it doesn't work.

from nodebb-plugin-write-api.

codecowboy avatar codecowboy commented on August 22, 2024

For anyone else having this issue, I also posted here - jaredhanson/passport-http-bearer#42

from nodebb-plugin-write-api.

julianlam avatar julianlam commented on August 22, 2024

@codecowboy Are you still experiencing issues getting the token parsed?

from nodebb-plugin-write-api.

codecowboy avatar codecowboy commented on August 22, 2024

@julianlam you can probably close this. I wrote a script which sets the appropriate headers for me.

from nodebb-plugin-write-api.

Related Issues (20)

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.