Coder Social home page Coder Social logo

Comments (3)

dschenkelman avatar dschenkelman commented on June 28, 2024

Hey @nicosabena,

Let's go with the static method idea, taking both clientId and domain parameters. It would nice to use a static Dictionary<string, RestClient> as a cache to avoid creating a new rest client every time it it called.

I think that is the best way to do it with the current code without breaking the API. Eventually if we see that more of these methods (that don't require clientSecret) are to be added to the API then we can introduce a better design with an Auth0Credentials object that takes care of GetToken() only if a clientSecret was provided when it was created (and otherwise throws).

Thanks,

from auth0.net.

nicosabena avatar nicosabena commented on June 28, 2024

The RestClient constructor is extremely lightweight, so I wouldn't worry about caching it.
Another option could be to have two "levels" of the Client instance:

  • The current one, when you provide both ClientId and ClientSecret in the constructor, that lets you access any method.
    var client = new Auth0.Client(clientId, clientSecret, domain);
    // I can do whatever I want, yeah!
    client.CreateConnection(...);
  • Another one, when you provide only the ClientId (and the domain, of course), that would only let you execute methods that do not require a token/clientSecret.
    var client = new Auth0.Client(clientId, domain);
    // restricted Access
    var token = client.LoginUser(...);
    // throws
    client.CreateConnection(); // SecurityException or something

I'm just thinking out loud here, but sound better tan the static method. Opinions?

from auth0.net.

dschenkelman avatar dschenkelman commented on June 28, 2024

@nicosabena I like the two constructors alternative. We need to update GetAccesToken to throw if no secret is provided.

Nice!

from auth0.net.

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.