Skip to content

OAuth2 with Flow("accessCode") on UI 3.x #3624

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

Closed
heldersepu opened this issue Aug 29, 2017 · 5 comments
Closed

OAuth2 with Flow("accessCode") on UI 3.x #3624

heldersepu opened this issue Aug 29, 2017 · 5 comments

Comments

@heldersepu
Copy link
Contributor

heldersepu commented Aug 29, 2017

Q A
Bug or feature request? Bug (Maybe)
Which Swagger/OpenAPI version? 2
Which Swagger-UI version? 3.x
How did you install Swagger-UI? Swagger-Net & Swashbuckle
Which browser & version? Chrome
Which operating system? Win7

Demonstration UI

Here is the 3.x UI sample that throws the error
http://swagger-netoauth2.azurewebsites.net/swagger
And here is the same under 2.x
http://swashbuckleoauth2.azurewebsites.net/swagger

Expected Behavior

There should not be any errors when we click on Authorize button.

Current Behavior

Getting errors:

- Auth Warning Authorization may be unsafe, passed state was changed in server Passed state wasn't returned from auth server
- Auth Error Authorization failed: no accessCode received from the server

Context

I've been simplifying the supported auth (Basic, ApiKey & OAuth2) configurations and ran into an issue with OAuth2. It seems that it was working before under 2x but now on 3x we get errors.
...Or it could be an error on my migration to 3.x

@heldersepu
Copy link
Contributor Author

heldersepu commented Sep 2, 2017

@shockey @webron Guys I really could use your help troubleshooting this.
Any pointers will be greatly appreciated.

@heldersepu
Copy link
Contributor Author

Found the problem:

var qp = null;
if(/code|token|error/.test(window.location.hash)) {
  qp = location.hash.substring(1);
}
else {
  qp = location.search.substring(1);
}
qp = (window.location.hash || location.search).substring(1);

I did test removing the window.location.hash || and bye-bye errors.
Yes it is a BUG no maybe anymore...

@heldersepu heldersepu changed the title OAuth2 on UI 3.x OAuth2 with Flow("accessCode") on UI 3.x Sep 3, 2017
@jmsvl
Copy link

jmsvl commented Sep 5, 2017

Helder helped me pinpoint the source of this bug and I'm also waiting for a fix. Is there any idea of an estimated time of repair?
Thanks

@shockey shockey closed this as completed in 947953d Sep 5, 2017
shockey added a commit that referenced this issue Sep 5, 2017
@shockey
Copy link
Contributor

shockey commented Sep 5, 2017

This was fixed in #3632, the fix should be released this Friday 🎉

Closing!

owenconti added a commit that referenced this issue Sep 16, 2017
* Updated docs for correct usage of SWAGGER_JSON

* Removed href attribute from anchor tag if deeplinking is disabled

* If deeplinking is disabled the anchor tag has no href attribute as a result the mouse pointer is not a pointer as it is no longer a hyperlink, setting the cursor explicitly to pointer.

* Refactor: use ternary operators at attribute level instead of element level

* Only polyfill Promise if it doesn't exist at all

* v3.1.7

* Typo fix

* fix #3624

* Squash commit: OAS3 Try-It-Out changes

* Parse JSON requestBodies so Client can consume them correctly

* Use Client branch

* Fix typo in swagger-client dependency

* Fix property names being displayed in array models

* Working on refactoring of model.jsx

* Fit linter and tests

* Add comment to array-model for to clarify change. Rework logic in `Model.render()` to fix bug with overriding name and schema from `$ref` definition.

* v3.2.0

* fromJS does not maintain order of object properties. Use a reviver function with fromJS inside the response.jsx component for the passed down schema prop.

* OAS3 Accept header control: Component-side

* OAS3 Accept header control: State-side

* Update response.jsx to use already existing, fromJSOrdered function

* Added test for response.jsx to make sure properties are passed to `ModelExample` component in the correct order

* Remove `it.only` from new test

* Fixes #3596

Wrap `isShownKey` values in a function that replaces spaces with underscores. When parsing the hash on route change, replace the spaces in the values with underscores again.

* Replace spaces with underscores when setting the hash value and inserting the ID into the DOM. Escape the deep link path when querying for the DOM element on hash change.

* Handle null value in createDeepLinkPath

* Add extra check for String types in `createDeepLinkPath`. Add `trim()` call on passed-in value in `createDeepLinkPath`. Added unit tests for new deep link util functions.

* LINTING!

* Roll back win import removal

Lost in merge conflict....

* More merge oversights...
ravanscafi pushed a commit to leroy-merlin-br/swagger-ui that referenced this issue Jan 24, 2018
@lock lock bot locked and limited conversation to collaborators Jul 3, 2019
JuanSW18 pushed a commit to Digital-Paw/digital-paw-swagger-ui that referenced this issue Aug 23, 2024
JuanSW18 pushed a commit to Digital-Paw/digital-paw-swagger-ui that referenced this issue Aug 23, 2024
* Updated docs for correct usage of SWAGGER_JSON

* Removed href attribute from anchor tag if deeplinking is disabled

* If deeplinking is disabled the anchor tag has no href attribute as a result the mouse pointer is not a pointer as it is no longer a hyperlink, setting the cursor explicitly to pointer.

* Refactor: use ternary operators at attribute level instead of element level

* Only polyfill Promise if it doesn't exist at all

* v3.1.7

* Typo fix

* fix swagger-api#3624

* Squash commit: OAS3 Try-It-Out changes

* Parse JSON requestBodies so Client can consume them correctly

* Use Client branch

* Fix typo in swagger-client dependency

* Fix property names being displayed in array models

* Working on refactoring of model.jsx

* Fit linter and tests

* Add comment to array-model for to clarify change. Rework logic in `Model.render()` to fix bug with overriding name and schema from `$ref` definition.

* v3.2.0

* fromJS does not maintain order of object properties. Use a reviver function with fromJS inside the response.jsx component for the passed down schema prop.

* OAS3 Accept header control: Component-side

* OAS3 Accept header control: State-side

* Update response.jsx to use already existing, fromJSOrdered function

* Added test for response.jsx to make sure properties are passed to `ModelExample` component in the correct order

* Remove `it.only` from new test

* Fixes swagger-api#3596

Wrap `isShownKey` values in a function that replaces spaces with underscores. When parsing the hash on route change, replace the spaces in the values with underscores again.

* Replace spaces with underscores when setting the hash value and inserting the ID into the DOM. Escape the deep link path when querying for the DOM element on hash change.

* Handle null value in createDeepLinkPath

* Add extra check for String types in `createDeepLinkPath`. Add `trim()` call on passed-in value in `createDeepLinkPath`. Added unit tests for new deep link util functions.

* LINTING!

* Roll back win import removal

Lost in merge conflict....

* More merge oversights...
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants