Skip to content
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

[csharp] Add scope for oauth2 #19175

Closed
wants to merge 23 commits into from
Closed

[csharp] Add scope for oauth2 #19175

wants to merge 23 commits into from

Conversation

mjansrud
Copy link
Contributor

@mjansrud mjansrud commented Jul 16, 2024

[csharp] Add scope for oauth2 based on issue #17047.

When using the OAuth client credentials flow, the Configuration object allows me to specify the OAuthTokenUrl, OAuthClientId, and OAuthClientSecret, but there seems to be no way to specify any scope. Problem I'm facing is that I need to specify a scope to retrieve a token, so currently the request made in the OAuthAuthenticator.cs (GetToken() method) class returns a 400 response.

Microsoft identity platform documentation:
https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-client-creds-grant-flow

image

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh ./bin/configs/*.yaml
    ./bin/utils/export_docs_generators.sh
    
    (For Windows users, please run the script in Git BASH)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.6.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@iBicha

@mjansrud mjansrud marked this pull request as ready for review July 16, 2024 14:57
@wing328
Copy link
Member

wing328 commented Jul 16, 2024

thanks for the PR. can you please review the test failures when you've time?

@mjansrud
Copy link
Contributor Author

I added LangVersion 8 to enable nullable strings in the netstandard2.0 sample projects to fix the tests. Im not sure if this is a ok solution, or if we want to solve the issue in another way. What do you think @wing328 ?

@wing328
Copy link
Member

wing328 commented Jul 17, 2024

I added LangVersion 8 to enable nullable strings

can it be avoided if possible?

@mjansrud
Copy link
Contributor Author

I think i found a decent solution by only setting the string as nullable on supported frameworks with templating rules. It seems like the variable can be set as a regular string in netstandard2.0, but still be defined as null. See the image screenshot attached. Can you run the rest of the tests? :)

image

@wing328
Copy link
Member

wing328 commented Jul 17, 2024

looks like some samples are not yet up-to-date: https://github.com/OpenAPITools/openapi-generator/actions/runs/9970910212/job/27553889552?pr=19175

can you please regenerate the samples when you've time?

@mjansrud
Copy link
Contributor Author

Ive updated the samples @wing328

@mjansrud
Copy link
Contributor Author

mjansrud commented Jul 19, 2024

Ive changed to {{nrt?}} as requested @devhl-labs. Does it look ok? And can one of you please generate the samples for me? That would be much appreciated @wing328 @devhl-labs. Upon test generation i get a deviation from main, and have to change the code manually, which is a real pain.

image image

@mjansrud mjansrud requested a review from devhl-labs July 19, 2024 10:12
@mjansrud
Copy link
Contributor Author

@wing328 can you run the last tests and take a final look?

@wing328
Copy link
Member

wing328 commented Jul 22, 2024

@mjansrud
Copy link
Contributor Author

Hi Wing. Did you see comment #19175 (comment)?

@wing328
Copy link
Member

wing328 commented Jul 24, 2024

filed #19234 with updated samples. let's see how that goes

@wing328 wing328 mentioned this pull request Jul 24, 2024
5 tasks
@wing328 wing328 closed this Jul 24, 2024
@wing328
Copy link
Member

wing328 commented Jul 25, 2024

@mjansrud thanks for the PR, which has been merged via #19234 with updated samples (all tests passed)

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