GithubHelp home page GithubHelp logo

adding concur provider about grant HOT 11 CLOSED

dominiksteiner avatar dominiksteiner commented on April 28, 2024
adding concur provider

from grant.

Comments (11)

simov avatar simov commented on April 28, 2024

Hi, @dominiksteiner, thanks for reaching out. I noticed that fork, and I'll take a look at it these days 👍

Generally adding a new provider is just a matter of adding a configuration in the config/oauth.json. The amount of other changes needed depends on how much exactly the provider in question deviates from the official OAuth specification.


On a side note: having configuration like gdrive and gmail in config/oauth.json is not needed. You can define static overrides in your configuration:

"google": {
  "gdrive": {"scope": []},
  "gmail": {"scope": []}
}

Then navigate to /connect/google/gdrive or /connect/google/gmail.

from grant.

simov avatar simov commented on April 28, 2024

There you go 2ecc996 @szafarcin @dominiksteiner let me know what do you think.

The next release will be published the next week, so in the meantime you can pull master and test.

The output format is as follows:

{
  "access_token": "...",
  "refresh_token": "...",
  "raw": "raw xml string"
}

If you need anything else than the access_token and the refresh_token you can parse the raw key on your own.

from grant.

dominiksteiner avatar dominiksteiner commented on April 28, 2024

wow, incredible, looks good, will test it, thanks for this quick integration.

from grant.

simov avatar simov commented on April 28, 2024

Also what's currently missing from the docs is that the following is identical:

// Express
var Grant = require('grant-express')
var Grant = require('grant').express()
// Koa
var Grant = require('grant-koa')
var Grant = require('grant').koa()
// Hapi
var Grant = require('grant-hapi')
var Grant = require('grant').hapi()

For Koa you need two additional dependencies: thunkify and koa-route

So you can require Grant directly in your app, without the need of meta module.

from grant.

dominiksteiner avatar dominiksteiner commented on April 28, 2024

Thanks, that's useful information too.

from grant.

szafarcin avatar szafarcin commented on April 28, 2024

@simov, just tested concur change seems to be returning access/refresh tokens fine.

However there is a slight further requirement based on the same fork. We are passing custom variables to corresponding callback if they are present in initial request. If you take a look at utils.js, we are binding variables (id,pwd,xsp,rurl etc) to provider and retrieving them in the callback for further use.
What do you suggest a best way to utilize such feature in grant?

Thanks

from grant.

simov avatar simov commented on April 28, 2024

Hi, @szafarcin, I'm not seeing such parameters in the official API docs.

That seems to be part of your own application logic. If I'm understand you correctly you want to store some user data and use it in the final callback? If that's the case the easiest way would be to store it in the user's session on connect and then access it in the final callback.

from grant.

szafarcin avatar szafarcin commented on April 28, 2024

Hi @simov ,

Yes correct, I was referring to variables mapped in https://github.com/szafarcin/grant/blob/master/lib/utils.js

Correct me if I am wrong regarding storing in session wouldn't that be part of grant itself as "connect" is called inside, and external app which uses grant just has the callback hook?. So what do you suggest for hooking data without changing in grant master. Thanks

from grant.

simov avatar simov commented on April 28, 2024

I think we're on the same page. The first thing that comes to my mind is this:

// navigate to /connect_concur instead of /connect/concur
app.use('/connect_concur', function (req, res) {
  req.session.user = {
    // store the current user's data
  }
  res.redirect('/connect/concur')
})

app.use('/final_callback', function (req, res) {
  // depending on your configuration
  // the OAuth response data is either in:
  req.query
  // or
  req.session.grant
  // the user's data that you stored previously in the connect route is in:
  req.session.user
})

Storing user data in grant.config is actually a bad practice. If you have two users connecting at the same time, the user data there will be incorrect. That's why it's better to store the user's data in its session.

from grant.

szafarcin avatar szafarcin commented on April 28, 2024

@simov thanks a lot for the clarification, and valuable input.

from grant.

simov avatar simov commented on April 28, 2024

Version 3.5.1 is published.

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.