Authentication won't work:
See original GitHub issueBy having next setup:
import { AUTH_LOGIN, AUTH_LOGOUT, AUTH_CHECK } from 'admin-on-rest';
export const authClient = (type, params) => {
if (type === AUTH_LOGIN) {
const { username, password } = params;
localStorage.setItem('username', username)
localStorage.setItem('token', btoa(username + ":" + password));
return Promise.resolve();
}
if (type === AUTH_LOGOUT) {
localStorage.removeItem('username');
localStorage.removeItem('token');
return Promise.resolve();
}
if (type === AUTH_CHECK) {
return localStorage.getItem('username') ? Promise.resolve() : Promise.reject();
}
return Promise.reject('Unkown method');
};
And :
const httpClient = (url, options) => {
if (!options.headers) {
options.headers = new Headers({ Accept: 'application/json' });
}
const token = localStorage.getItem('token')
options.headers.set('Authorization', `Basic ${token}`);
return fetchUtils.fetchJson(url, options);
}
const restClient = simpleRestClient('http://localhost:30120/api', httpClient);
class App extends Component {
render() {
return (
<Admin authClient={authClient} dashboard={Dashboard} restClient={restClient}>
...
Getting 401 error every-time during call to API
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Common problems with two-step verification for a work or ...
First, make sure you typed the password correctly. If that doesn't fix it, try creating a new app password for the app. Do...
Read more >Fix common issues with 2-Step Verification - Google Support
My Google Authenticator codes don't work · On your Android device, go to the main menu of the Google Authenticator app. · Tap...
Read more >How to Fix Google Authenticator Codes That Have Stopped ...
How to Fix Google Authenticator Codes That Have Stopped Working · 1. Sync the App's Time · 2. Update the Authenticator App ·...
Read more >What should I do if I've activated 2FA, but lost access to the ...
What should I do if I've activated 2FA, but lost access to the authentication app or it is not working? There are several...
Read more >Troubleshoot login with two-factor authentication on Facebook
If you don't have access to your phone, or you no longer have access to your two-factor authentication method, select I don't have...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The CORS headers must be set on your API endpoint. There is nothing specific to admin-on-rest here that we could document, because admin-on-rest only deals with the client side.
If you want instructions on how to do that, just google “setup cors headers”.
@louizaOU we don’t provide support via GitHub issues, please post your question on StackOverflow.