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

VS Code: JSON Preview shows form requesting API key and Submit does nothing. #66

Open
robws opened this issue Apr 29, 2024 · 13 comments
Open

Comments

@robws
Copy link

robws commented Apr 29, 2024

I pressed Preview while viewing a swagger.json file, and the preview screen showed "Want to see a context aware preview of your docs?" with a text box for API key. Adding my API key - even generating a new one - and pressing Submit had no effect.

What should have happened instead?
Assuming pressing Submit would authenticate me with Redocly and show the OpenAPI Preview.

Minimal reproducible OpenAPI snippet
No snippet results in correct behavior; this does not appear to be a factor of the OpenAPI itself.

If possible, include a short example of your OpenAPI definition that we can use to simulate the problem.

Screenshots
image

If applicable, add screenshots to help explain your problem.

Additional context

Add any other information about the problem here, like: the extension version number; OpenAPI version you're using in your definition; your operating system.
Latest extension, Mac, VS Code latest version.

@tatomyr
Copy link
Contributor

tatomyr commented Apr 29, 2024

That's strange. Could you check if logging via Redocly CLI helps here? For that, please run npx @redocly/cli login, then close and reopen your editor. Then try the 'Preview' feature again.

@robws
Copy link
Author

robws commented Apr 30, 2024

Where do I run that from, and will it leave anything in my system I don't expect? When I first ran it it seemed to put something in NPM.

It says "Need to install the following packages:
@redocly/[email protected]"

What does that do?

@robws
Copy link
Author

robws commented Apr 30, 2024

I see this:
image

Which is bogus, because you can't literally get your API key from that address (you would have had to have retrieved it when you created it)

And pasting it doesn't result in anything other than "logging in..." then a return to the prompt.

@robws
Copy link
Author

robws commented Apr 30, 2024

Restarting VS Code has the same behavior as described.

@tatomyr
Copy link
Contributor

tatomyr commented May 1, 2024

I see. It looks like you're using an expired or revoked key. The message should look like the following:

Screenshot 2024-05-01 at 08 20 18

Please follow the link and generate a new key. 

This can also explain why you cannot log in directly with the extension. This is a bug, indeed. There should be a warning in case of a wrong key.

It says "Need to install the following packages:
@redocly/[email protected]"

What does that do?

It installs Redocly CLI (which the extension is driven by) in your local NPM cache.

@tatomyr tatomyr added the p3 label May 1, 2024
@robws
Copy link
Author

robws commented May 1, 2024

Thank you! I'll make another key and give it a shot. I was confused why the preview window didn't seem to do anything when I pressed submit. I was watching and developer tools to see if there were any network traffic, and didn't see any JS errors. But I guess there wouldn't be if you coded it to trap errors!

I wasn't sure about whether or not I pasted the right thing into the CLI, because of course it doesn't show you the text of what you paste and sometimes you're not sure if you put other characters into that prompt at all.

@robws
Copy link
Author

robws commented May 1, 2024

It is indeed our VPN, Cloudflare Warp Zero-Trust, as the authorization works fine when I turn it off, as does the extension to preview.

I didn't realize this at first, as the preview was failing, and possibly has multiple reasons for failure. I'm assuming when it can't reach the redocly servers, it perpetually shows the "Log in" form screen.

@tatomyr
Copy link
Contributor

tatomyr commented May 3, 2024

I'm assuming when it can't reach the redocly servers, it perpetually shows the "Log in" form screen.

Yes. It relies on authenticating through a Redocly endpoint, so the VPN have to be configured appropriately for the extension to be able to verify the token.

@robws
Copy link
Author

robws commented May 3, 2024

Once the token is verified, does any more communication happen?

I suspect the company would probably want to know if API specs must be sent to our stored at redocly, or if the preview tool can be used otherwise.

@tatomyr
Copy link
Contributor

tatomyr commented May 3, 2024

The extension tries to verify the token each time it gets loaded. So (more or less) each time you reopen the editor it will send a request to the Redocly API.

@romanpryshliak
Copy link

Currently, the extension doesn't accept the personal API key for me. However, I managed to get it working with an organization API key from Redocly Workflows: Image

@leodolbir
Copy link

leodolbir commented Nov 22, 2024

I observed the problem described above and unable to use the preview. I was however able to login through the CLI, so I'm confident the VPN has nothing to do with it. Also looking through developer tools there are input fields and the button but no form to submit or a javascript handler
Image

@jmehnle
Copy link

jmehnle commented Dec 16, 2024

I, too, am suffering from this problem: I paste my personal API key into the "API key" input field in the preview tab and click "Submit", yet absolutely nothing happens. I can click the button many times, to no avail. I have the redocly CLI installed via npm, and I can run it on the shell.

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

No branches or pull requests

5 participants