TypeError: authProvider.checkAuth is not a function
See original GitHub issueWhat you were expecting:
login pageWhat happened instead:
TypeError: authProvider.checkAuth is not a functionSteps to reproduce:
Only added App.js and authProvider.jsRelated code:
import * as React from "react";
import authProvider from './authProvider';
import { Admin, Resource, ListGuesser } from 'react-admin';
import jsonServerProvider from 'ra-data-json-server';
const dataProvider = jsonServerProvider('https://jsonplaceholder.typicode.com');
const App = () => (
<Admin dataProvider={dataProvider} authProvider={authProvider}>
<Resource name="users" list={ListGuesser} />
</Admin>
);
export default App;
Other information:
Environment
- React-admin version:^3.8.2
- Last version that did not exhibit the issue (if applicable):
- React version:^16.13.1
- Browser:Chrome
- Stack trace (in case of a JS error):
(anonymous function)
E:/code/my-app/node_modules/ra-core/esm/auth/useCheckAuth.js:49
46 | if (params === void 0) { params = {}; }
47 | if (logoutOnFailure === void 0) { logoutOnFailure = true; }
48 | if (redirectTo === void 0) { redirectTo = defaultAuthParams.loginUrl; }
> 49 | return authProvider.checkAuth(params).catch(function (error) {
| ^ 50 | if (logoutOnFailure) {
51 | logout({}, error && error.redirectTo
52 | ? error.redirectTo
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Writing An Auth Provider - React-admin - Marmelab
Here is the interface react-admin expect authProvider objects to implement. const authProvider = { // authentication login: params => Promise.resolve(/* .
Read more >Why do I not get redirected to /login when accessing a secure ...
It is offered to change the redirect using an argument to rejected promise: checkAuth: () => localStorage. getItem('token') ? Promise.
Read more >Auth | JavaScript SDK | Firebase JavaScript API reference
Enable email/password accounts in the Firebase Console, under the Auth tab. auth/weak-password: Thrown if the password is not strong enough. example.
Read more >[Solved]-How to use Auth0 with react-admin?-Reactjs
My answer is following react-admin approach where I use its authProvider like below. ... Convert authProvider into function where it takes the above...
Read more >Source - GitHub
Changelog ## v4.5.2 * Fix `authProvider` hooks support for redirectTo: ... Fix `useGetManyAggregate` throws "filter is not a function" when getting 401 ...
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 FreeTop 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
Top GitHub Comments
yes you’re right, the sample code is incomplete, probably intentionally since it would be pretty obvious; you may overcome this with looking at the type of
AuthProvider
innode_modules/ra-core/src/types.ts
, there you will see minimum amount of methods necessary for good working authenticator, however, experience proves, you need only 3 of those:login, checkAuth and getPermissions
, so for the other use temporary work around to see the direct output:please, note, that in order to build fully functioning, secure authenticator you may need to fully implement all those functions. Regards.
We would gladly accept a PR to fix it 😃