function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Brian Barrett 5Brian Barrett 5 

Web API with Javascript

I have a requirement to use JavaScript to access opportunities over REST API. This will be done from an in house web-based application that only allows for custom code to be in JS. I am trying to authenticate with Oauth2

I have successfully been able to send the initial login request for a authorization code. i can take that out of the url and use it to attempt to authorize for an access token. I have tried two approaches

1) I made a hidden form to submit all required information as POST data, i successfully authenticate, however i land on a XML page that has the token and nothing else. it doesn't seem to redirect to my site, just open the xml page

2) I have tried to send an AJAX request, but I get pre-flight errors since it's trying to redirect my page

What do i need to do to receive the response in JavaScript? I'm assuming this is possible and that i do not need to use server side scripting.

thank you for your time and help,
-Brian
Brian Barrett 5Brian Barrett 5
Also, pointing out any glaring security no-nos with my approach is welcome. i feel a little skethy giving js my client secret