Skip to content

feat: Add data:application/json;base64 support to AuthenticationOauth2 #263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

chriscameron-vertexinc
Copy link
Contributor

Added support for using OAuth2 with a base64 encoded string instead of a file path.

Workaround for #253

raise <| NotSupportedException($"Content type '{contentType}' is not supported.")

let deserializeCreds (privateKey: Uri) =
backgroundTask {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would write it as

match privateKey.Scheme with
| "file" ->
    openAndDeserializeCreds privateKey.LocalPath
| "data" ->
    decodeAndDeserializeCreds privateKey |> Task.FromResult
| _ ->
    raise <| NotSupportedException $"Scheme '{privateKey.Scheme}' is not supported."

and would also skip .ToLowerInvariant()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having a lot of trouble with this one. The mixing of sync and async is resulting in casting issues.

@chriscameron-vertexinc
Copy link
Contributor Author

@Lanayx I've been able to drop these changes into my application and verify that the base64 credentials decode is working.

@Lanayx Lanayx merged commit ad89cbb into fsprojects:develop May 15, 2024
2 checks passed
@chriscameron-vertexinc chriscameron-vertexinc deleted the feat-oauth2-data-scheme branch June 17, 2024 15:41
@DanBiscotti
Copy link

Hi I'm hoping to use this feature in a .NET Framework project using the 2.x branch, but it looks like it hasn't been merged into that branch. I was able to apply the changes to that branch, although I had to change one line:
match credentialsUrl.LocalPath.Split(',', 2) with -> match credentialsUrl.LocalPath.Split([| ',' |], 2) with
I tested and it seems to work, is it ok to get this change on the 2.x branch as well?

@Lanayx
Copy link
Member

Lanayx commented May 18, 2025

Yes, it is ok, you are welcome to send a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants