Git Product home page Git Product logo

Comments (4)

simov avatar simov commented on April 28, 2024 1

No, I haven't open sourced the showcase app yet. But with the amount of docs and examples here it shouldn't be that hard to figure out what I have on the server.

The first thing is to have configuration for each provider, but in this case I have only the provider's application key and secret set. The next important thing is to have a single final callback on your server for all providers, you can set it in server:{callback:'/handle_all'}. In that route you receive not only the response data from the OAuth flow, but the provider name as well under the provider key in the querystring or in the session.

The rest of the code is in the browser, I have a web form that makes POST request to the connect route using the Dynamic Override feature. The actual form fields come from yet another JSON configuration that I have compiled by reading each and every provider's developer docs.

from grant.

simov avatar simov commented on April 28, 2024 1

Maybe you can have a look at the articles listed in this thread #202, specifically this one https://dev.to/simov/oauth-like-a-boss-2m3b. It has an example of how to extract the access token from the callback URL.

Try this:

  • add two login buttons on your page using two different providers
  • setup Grant and your OAuth apps
  • click on those login buttons, in the end you should be redirected back to your login page or some other route
  • extract the access token

That's basically what the OAuth Playground app does.

Then you can start playing around with different things: maybe you want to add a little bit of logic in your server routes, or maybe you want to send some dynamic parameters from the browser to configure the login flow. How are you going to persist the user session? Are you going to use a cookie or localStorage, and so on.

Note that for all of those basic cases, at least on the server side, you can simply copy/paste an example from the examples folder, configure it and start using it. Separate example repositories are available for every cloud environment, you can find the links at the bottom of the Handlers section https://github.com/simov/grant#handlers

from grant.

evancohen avatar evancohen commented on April 28, 2024

Most excellent! Thanks for the detailed response :)

from grant.

jlarmstrongiv avatar jlarmstrongiv commented on April 28, 2024

@simov I’m currently learning grant. Are you considering open-sourcing the OAuth Playground? It’d be helpful to learn from πŸ˜„

from grant.

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.