Developer Portal SmartDocs oAuth issue

Hello!

I’ve been testing oAuth for the live documentation (SmartDoc) in the Custom Developer Portal and something seems not to work.

I have attached two screenshots to help my explanation.

So…

  1. The proxy spec contains oAuth as a security Scheme.
  2. SmartDocs picks it up as expected and shows an “Authenticate” button.
  3. When I click on that button, then add the Client ID and Client Secret on the popup, and hit “Authorize” it won’t work and it will fail with an error “Failed to load resource: Preflight response is not successful.” (see the first file attached)
  4. The curious thing is that if I debug the portal code, with the browsers developer tools, and export the “Authorize” network request as a curl command….then run it on a Terminal…it works fine. (see the second file attached)

Thanks!

Solved Solved
0 4 263
1 ACCEPTED SOLUTION

Hi @nicolas badano - This very likely is because the proxy is missing support for CORS. Refer to the following documentation to add CORS support: https://docs-new.apigee.com/publish-apis

View solution in original post

4 REPLIES 4

Hi @nicolas badano - This very likely is because the proxy is missing support for CORS. Refer to the following documentation to add CORS support: https://docs-new.apigee.com/publish-apis

Thanks @arungopal! I will look into this. But by doing a quick read of the link you've sent I think you are spot on. I'll let you know as soon as I give this a try.


@arungopal I have added CORS policy and CORS preflight as per the link you suggested. But it's still not working. If I perform a trace I can see the request is actually an OPTIONS one but it's failing with status 401 and {"ErrorCode" : "invalid_client", "Error" :"Client identifier is required"}. If I ran the curl command, the trace shows a POST request and everything works fine. So if I understand correctly, the web browser, or the developer portal, is sending the OPTIONS request in my behalf, but it's not attaching the correct credentials in the header, how can I fix this? Maybe I'm getting this whole thing wrong (pardon my ignorance, I'm no web developer...just an apps developer trying to make a backend work).

@nicolas badano - you are good, i see another user who has run in to the same issue. Refer : https://community.apigee.com/questions/64713/developer-portal-5.html . Let me know if the solutions proposed there help.