AzureAuth icon indicating copy to clipboard operation
AzureAuth copied to clipboard

Add PKCE support

Open mattmalcher opened this issue 2 years ago • 2 comments

Curious about the current status of this package, have a requirement to authenticate to Azure AD using Auth Code + PKCE flow which is not supported as-is.

Basically looking to understand:

  • chances of someone adding pkce flow / moving this package to httr2
  • chances of being able to make a pull request & have it accepted, and update the package on CRAN

From what I can tell hongooi73 has moved on from microsoft.

I can see there is a branch and issue working on implementing httr2, but the last activity is Oct 21.

It doesn't look like pull requests are being accepted https://github.com/Azure/AzureAuth/pull/71

Is the best approach to fork?

mattmalcher avatar Mar 09 '23 17:03 mattmalcher

Note I'm still around, although I've been less active recently. Do you have specific functionality in httr2 that isn't present in the current package?

hongooi73 avatar Aug 01 '23 12:08 hongooi73

Glad to hear it :) Sorry if I'm misunderstanding the question, but:

The functionality that is in httr2, that I don't believe is in the current version of AzureAuth is the ability to use the auth code + PKCE flow.

My reason for thinking this was the lack of a flag for PKCE and that I understand the current package is based on httr's OAuth implementation, which while it supports auth code, does not support auth code + pkce. (https://github.com/r-lib/httr/issues/705).

Because I am required to use PKCE I am using something like the following to construct my graph requests manually:

    client <- httr2::oauth_client(
      id = client_id,
      token_url = paste0(
        "https://login.microsoftonline.com/", tenant_id, "/oauth2/v2.0/token"
      )
    )

    httr2::req_oauth_auth_code(
      req,
      client = client, 
      auth_url = auth_url, 
      **pkce=TRUE**
    ) 

I have used the httr2 branch you put together successfully (thank you!), but its harder to use where I need to use it, while it remains as a branch, not in CRAN.

I guess I was hoping it might be possible to get that branch merged in, if not, no worries and thanks either way, really appreciate that this package exists and feel cheeky asking for more!

mattmalcher avatar Aug 01 '23 13:08 mattmalcher