Add all declared scopes is auth.oauth2.scopes discovery file section#92
Conversation
Codecov Report
@@ Coverage Diff @@
## master #92 +/- ##
============================================
+ Coverage 80.02% 80.09% +0.06%
- Complexity 1681 1689 +8
============================================
Files 156 157 +1
Lines 5597 5626 +29
Branches 731 732 +1
============================================
+ Hits 4479 4506 +27
- Misses 838 841 +3
+ Partials 280 279 -1
Continue to review full report at Codecov.
|
tangiel
left a comment
There was a problem hiding this comment.
Apologies for the slow review.
| @@ -0,0 +1,219 @@ | |||
| #Source: https://developers.google.com/identity/protocols/googlescopes | |||
There was a problem hiding this comment.
Is this file generated or hand written? Might be a hassle to keep up to date.
There was a problem hiding this comment.
Keys and values were extracted separately using the xpath expressions below, and merged in a spreadsheet.
Then some transformations were performed to deduplicate, sort the entries and add comments.
All of this could be easily automated, but I was hoping you had an "official" list of scope descriptions at Google.
This would be much better than scrapping a web page. Do you know if something like that exists?
420aa53 to
6e3550b
Compare
6e3550b to
17e4de6
Compare
Move scopeDescriptions.properties to DiscoveryGenerator packge
|
Hi @tangiel , |
| } | ||
|
|
||
| LinkedHashMap<String, ScopesElement> scopeElements = new LinkedHashMap<>(); | ||
| for (String scope : allScopes) { |
There was a problem hiding this comment.
Presumably this doesn't work when multiple scopes are required? What would happen if the scope expression is "email profile" for example?
There was a problem hiding this comment.
Indeed, but is this how the @Api*.scopes field is supposed to be used?
It is a String array, so I assumed each scope must be declared independently.
i.e. @apimethod(scopes = {"email", "profile"}) rather than @apimethod(scopes = {"email profile"})
There was a problem hiding this comment.
This probably needs to be documented better, but the comma separation is a logical OR for scopes. To require multiple scopes simultaneously you are supposed to use one string with space separation.
- follows the schema repository pattern already used in DiscoveryGenerator - could be reused for swagger generation (if / when supporting accessToken security definition) - added some tests for proper merging of existing scope declarations
|
I extracted the logic for scope description handling to its own class, should be clearer. |
|
I don't know if you saw my comment since it was in an outdated comment, but: This probably needs to be documented better, but the comma separation is a logical OR for scopes. To require multiple scopes simultaneously you are supposed to use one string with space separation. |
|
I just updated the PR to handle scope conjunction expressions properly. And I learned something about scope expressions :-) |
|
Thanks @clementdenis, sorry it took so long to review. |
Currently, only the email scope is asked by the API explorer, because other scopes declared by APIs and API methods are not aggregated in the discovery file.
This brings Cloud Endpoints on par with the behavior of Google own APIs.