Skip to content

Need support for 'client_credentials' in authenticate (for External Client Apps) #108

Description

@dwindibank

The nforce8 authenticate method doesn't support the client_credentials grant_type. Salesforce is requiring a migration from Connected Apps to External Client Apps. External Client Apps don't support username-password flow.

From: Comparison of Connected Apps and External Client Apps Features

  1. External client apps use OAuth protocols to authorize third-party apps. However, there are some OAuth features that are available for connected apps but aren’t available for external client apps. For example, the OAuth username-password flow won't be made available for external client apps.

Adding the support isn't hard, just need to add an else to set client_credentials as the grant_type:

//TODO: Add JWT authentication
  if (opts.code) {
    bopts.grant_type = 'authorization_code';
    bopts.code = opts.code;
    bopts.redirect_uri = self.redirectUri;
  } else if (opts.assertion) {
    bopts.grant_type = 'assertion';
    bopts.assertion_type = 'urn:oasis:names:tc:SAML:2.0:profiles:SSO:browser';
    bopts.assertion = opts.assertion;
  } else if (opts.username || this.username) {
    bopts.grant_type = 'password';
    bopts.username = opts.username || this.getUsername();
    bopts.password = opts.password || this.getPassword();
    if (opts.securityToken || this.getSecurityToken()) {
      bopts.password += opts.securityToken || this.getSecurityToken();
    }
    if (this.mode === 'single') {
      this.setUsername(bopts.username);
      this.setPassword(bopts.password);
      this.setSecurityToken(bopts.securityToken);
    }
  } else {
    bopts.grant_type = 'client_credentials';
  }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions