r-lib / httr

httr: a friendly http package for R
https://httr.r-lib.org
Other
986 stars 1.99k forks source link

update demo/oauth2-azure.r to oauth2/v2.0 #754

Open klin333 opened 3 months ago

klin333 commented 3 months ago

In the azure demo, it suggests using a legacy endpoint. https://github.com/r-lib/httr/blob/df11e216f5e1a30f1bc8df8118e7cd983d9066f9/demo/oauth2-azure.r#L18-L24

It needs to be updated to the below, as outlined in Microsoft guide https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-auth-code-flow

endpoint <- httr::oauth_endpoint(
  authorize = sprintf("https://login.windows.net/%s/oauth2/v2.0/authorize", tenant_id),  # changed here by adding /v2.0/
  access = sprintf("https://login.windows.net/%s/oauth2/v2.0/token", tenant_id))

In addition httr::oauth_endpoints("azure") gives "https://login.windows.net/common/oauth2/authorize", which is no longer supported since 2018 I believe.

I can confirm this change is required.