I need to pull data from a 3rd-party REST API into a WordPress page. It's a search app so I would like to avoid page refresh and load results via AJAX if possible.
The API setup is as follows:
- User/password is required to get a bearer token (POST request, separate endpoint)
- Bearer token is required for every GET request to the API
- Token expires every 30 days
What are best practices for securing login credentials and token in a front-end application?
Even if authentication is handled on the server using wp_remote_post, how do I pass the token value to JavaScript without exposing it in the browser?