I have…
-Read the following guideline: https://docs.squidex.io/01-getting-started/installation/troubleshooting-and-support. I understand that my support request might get deleted if I do not follow the guideline.
- [ ] Used code blocks with ``` to format my code examples like JSON or logs properly.
I’m submitting a…
Un-authorized error 401- is been shown on the API call even if we have the headers set.
Current behavior
| The steps taken to configure the request header and Auth token in the project. No luck so far on the API success. |
---|---|
| Achieved : |
1) | The API we are trying to call is tested in Postman for confirming the response from the API which is working correctly. With the headers and Auth token, |
2) | The same parameters did not help is hitting the API – Facing Unauthorized error 401. |
| The challenge we are facing is on the React typescript and Axios configuration part , as the API calling is done from a Clous based URL which us Squidex in this case. |
| All the env steup is taken into .env file but we are facing the same issue as unauthorized error |
Expected behavior
Kindly help us out understand the parts around the API config in React Typescript with Axios.
Squidex -https://cloud.squidex.io/app/lsdbx-pip
Minimal reproduction of the problem
App.tsx:-
import React from ‘react’;
import ‘./App.css’;
import axios from ‘axios’;
import { useEffect } from ‘react’;
function App() {
// const [offer, setOffer] = useState();
useEffect(() => {
const apiUrl = "https://cloud.squidex.io/api/content/lsdbx-pip/pe-feeder-co-investment/";
const authToken = "Bearer " + "";
axios.request({
method: 'GET',
url: apiUrl,
headers: {
Authorization: authToken,
}
}).then((response) => {
console.log(response.data);
// setOffer(response.data);
});
}, []);
return
}
export default App;
Environment
.env file:-
API keys and secrets
REACT_APP_CLIENT_ID=‘lsdbx-pip:default’
REACT_APP_CLIENT_SECRET=‘xyz’
Database connection strings
REACT_APP_DB_HOST=your_db_host_here
REACT_APP_DB_PORT=your_db_port_here
REACT_APP_DB_NAME=your_db_name_here
REACT_APP_DB_USERNAME=your_db_username_here
REACT_APP_DB_PASSWORD=your_db_password_here
Hostnames and ports
REACT_APP_SERVER_HOST=your_server_host_here
REACT_APP_SERVER_PORT=your_server_port_here
Authentication credentials
#REACT_APP_AUTH_USERNAME=your_auth_username_here
#REACT_APP_AUTH_PASSWORD=your_auth_password_here
REACT_APP_AUTH_TOKEN=‘eyJhbGciOiJSUzI1NiIsImtpZCI6IjlTZWo3eXJYdGo1TzNDVV9JeG5EU2ciLCJ0eXAiOiJhdCtqd3QifQ’
Environment-specific settings
REACT_APP_ENVIRONMENT=development
Browser:
- [ ] Chrome (desktop)