GithubHelp home page GithubHelp logo

Comments (5)

PierrickP avatar PierrickP commented on June 15, 2024

Hello @testower
This is probably a nice update !

Can you make a PR ?
Are you a GBFS producer or consumer ? I'm not sure to have this kind on feed to correctly test it.

For the update, i would see a new option on auth select on website with 3 inputs (username / password / endpoint ?)
Then something here

this.auth = auth
this.gotOptions = {}
if (this.auth && this.auth.type) {
if (this.auth.type === 'basic_auth' && this.auth.basicAuth) {
this.gotOptions.headers = {
Authorization: `basic ${Buffer.from(
`${this.auth.basicAuth.user}:${this.auth.basicAuth.password}`,
'utf-8'
).toString('base64')}`
}
}
if (this.auth.type === 'bearer_token' && this.auth.bearerToken) {
this.gotOptions.headers = {
Authorization: `Bearer ${this.auth.bearerToken.token}`
}
}
}
}
to get the access token

from gbfs-validator.

testower avatar testower commented on June 15, 2024

From the point of view of this request I'm a consumer. Yes I'd be happy to make a PR on this.

Yes I think 3 options as you mention makes sense.

However, retrieving the access token in the constructor is a tricky affair since it needs to be an async operation, and constructors can't be async (?). So I think it maybe be better to do it lazily on the first actual request and then save the token for the subsequent requests.

Let me know if that makes sense.

from gbfs-validator.

testower avatar testower commented on June 15, 2024

I need to correct myself: While it is technically possible to make the constructor async / return a promise, it is a bit unorthodox and would possibly feel strange in this case, unless you actually need to use this particular feature.

from gbfs-validator.

PierrickP avatar PierrickP commented on June 15, 2024

Hello, sorry for the late reply.
I agree for the async constructor, it's a bad idea.
At first, i thinking of making the auth roundtrip on the frontend and return the access token to the back.
Or you can add an async function on the validation function https://github.com/MobilityData/gbfs-validator/blob/master/gbfs-validator/gbfs.js#L262 . Others functions are not write to be called outside of the class.

from gbfs-validator.

testower avatar testower commented on June 15, 2024

Yeah I think on the validation function is the better option. I'll have a PR ready today hopefully 👍

from gbfs-validator.

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.