Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[V2] Support grant type other than authorization code (e.g. JWT bearer or client credential) #1331

Closed
stomita opened this issue May 23, 2023 · 0 comments

Comments

@stomita
Copy link
Contributor

stomita commented May 23, 2023

As the current Connection#authorize() expects the first argument to be a code string returned from authorization server, which cannot be obtained for grant types other than authorization_code. It would be better to support other grant types by accepting the parameter object to pass the server as the first argument instead of code string.

For example, if you are going to do the JWT bearer grant:

const conn = new jsforce.Connection();
const claim = {
  iss: ISSUER,
  aud: AUDIENCE,
  sub: 'user01@mydomain.example.org',
  exp: Math.floor(Date.now() / 1000) + 3 * 60
};
const bearerToken = jwt.sign(claim, cert, { algorithm: 'RS256'});
await conn.authorize({
  grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
  assertion: bearerToken
});

In client credential grant:

const conn = new jsforce.Connection({
   oauth2: {
      clientId: CLIENT_ID,
      clientSecret: CLIENT_SECRET,
   },
});
await conn.authorize({ grant_type: 'client_credentials' });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant