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

feat: Expose scopes granted by user #1107

Merged
merged 9 commits into from
Dec 21, 2022

Conversation

sai-sunder-s
Copy link
Contributor

@sai-sunder-s sai-sunder-s commented Nov 30, 2022

Token response from the IDP contains scopes that were granted by the user. This PR adds functionality to expose those scopes to the developer code.

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> ☕️

If you write sample code, please follow the samples format.

@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label Nov 30, 2022
@sai-sunder-s sai-sunder-s force-pushed the partialconsent branch 2 times, most recently from 27616cc to f02442a Compare December 1, 2022 03:54
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Dec 13, 2022
@sai-sunder-s sai-sunder-s marked this pull request as ready for review December 13, 2022 23:07
@sai-sunder-s sai-sunder-s requested a review from a team as a code owner December 13, 2022 23:07
Copy link
Contributor

@TimurSadykov TimurSadykov left a comment

Choose a reason for hiding this comment

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

LGTM

Date expiresBy = null;
if (accessToken != null) {
acessTokenValue = accessToken.getTokenValue();
expiresBy = accessToken.getExpirationTime();
List<String> grantedScopes = accessToken.getScopes();

if (grantedScopes != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this should not be necessary, list can be serialized to json, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

List can be serialized but while deserializing it gets complicated. It is not possible to do an instance of check for List. I get this error: "Cannot perform instanceof check against parameterized type List. Use the form List<?> instead since further generic type information will be erased at runtime"

There are ways to deserialize like using Gson and seems to be another library called jackson that can help. But there is no need to complicate I think.

Copy link
Contributor

Choose a reason for hiding this comment

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

Its just had to be List ) Generic does not exist at runtime )

@sai-sunder-s sai-sunder-s requested a review from lsirac December 20, 2022 02:33
@sai-sunder-s sai-sunder-s merged commit 240c26b into googleapis:main Dec 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants