Problem/Motivation

I need to send 'resource' parameter to get Access token.
The request will be sent to https://login.microsoftonline.com//oauth2/token with below parameters
grant_type: client_credentials
resource: https://vhsdev.crm.dynamics.com/
client_id: ****
client_secret: ***

Proposed resolution

I couldn't find a way to add "resource" parameter. The MS Dynamics Oauth API returns invalid access token without resource parameter. Is it possible to add extra parameters before getting Access token?

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

khaldoon_masud created an issue. See original summary.

khaldoon_masud’s picture

StatusFileSize
new1.13 KB

Here is the patch I created.

Plugin definition:

/**
 * Ms dynamics events oauth2client plugin.
 *
 * @Oauth2Client(
 *   id = "ms_dynamics_events",
 *   name = @Translation("MS Dynamics Events"),
 *   grant_type = "client_credentials",
 *   authorization_uri = "https://login.microsoftonline.com/<hash>/oauth2/token",
 *   token_uri = "https://login.microsoftonline.com/<hash>/oauth2/token",
 *   resource_owner_uri = "",
 *   access_token_options = "resource=https://vhsdev.crm.dynamics.com/",
 * )
 */
fathershawn’s picture

Assigned: Unassigned » fathershawn
Status: Active » Needs review
fathershawn’s picture

fathershawn’s picture

fathershawn’s picture

The MR allows additional token request parameters to be added in plugin annotation. These are merged as additional parameters by the GenericProvider class in the League library

      *   request_options = {
      *     "parameter" = "value",
      *   },

So for the OP and others referred by similar issues, please test this MR for your use case.

fathershawn’s picture

fathershawn’s picture

Cleaned up some leakage from another issue

fathershawn’s picture

Category: Task » Feature request

fathershawn’s picture

fathershawn’s picture

@zerbash - Thanks for the review. If this revised version works for then I think we are ready to merge. As far as the new MR flow is concerned, instructions are at the top of the issue - just open Show commands details.

If you prefer a patch, just add the extension on to the merge request url:
https://git.drupalcode.org/project/oauth2_client/-/merge_requests/8.patch

  • FatherShawn committed 539aae4 on 8.x-3.x
    Issue #3256272 by FatherShawn, zerbash: Additional parameters to get...
fathershawn’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.