verbb / consume

A Craft CMS plugin to create HTTP requests in your Twig templates to consume JSON, XML or CSV content.
Other
4 stars 1 forks source link

Authorization URL/Token URL does not work for generic provider when set as environment variables. #14

Open jamesmacwhite opened 6 days ago

jamesmacwhite commented 6 days ago

Describe the bug

I used the Generic provider for OAuth to Microsoft Graph API whereby the Authorization URL and Token URL need to be set to the specific Azure/Entra Tenant ID endpoint of the environment the app exists in, rather than the standard login.microsoftonline.com endpoint.

This works fine, but as soon as the values are set as environment variables, when authenticating with the connect button, the URL becomes:

/admin/$SHAREPOINT_OAUTH_AUTH_URL?scope=[scope]&state=[state]&response_type=code&approval_prompt=auto&redirect_uri=[callback_url]&client_id=[client_id]

The appearance of $SHAREPOINT_OAUTH_AUTH_URL suggests the environment variable wasn't parsed.

Putting the values directly, allows the Generic client to be authenticated.

Steps to reproduce

  1. Create a client using the Generic Provider
  2. Set the Authorization and Token URL as environment variables
  3. Use the connection button to authenticate
  4. 404 control panel error due to the URL literally using the environment variable value

Craft CMS version

5.2.5

Plugin version

2.0.0

Multi-site?

No

Additional context

No response

jamesmacwhite commented 5 days ago

I have worked around this by using an extended class and overriding $urlAuthorize and $urlAccessToken in the class. However I'll leave this open, as I believe the environment variable has not been parsed.