dion
dion
Explore posts from servers
RRefine
Created by genetic-orange on 6/4/2024 in #ask-any-question
Bearer token for keycloak
Hi, am a little lost with the documentation as there doesn't seem to be much information on how the login works for the keycloak abstraction. This was what my project was generated with:
const authProvider: AuthProvider = {
login: async () => {
signIn('keycloak', {
callbackUrl: to ? to.toString() : '/',
redirect: true
});

return {
success: true
};
},
logout: async () => {
signOut({
redirect: true,
callbackUrl: '/login'
});

return {
success: true
};
},
onError: async (error) => {
if (error.response?.status === 401) {
return {
logout: true
};
}

return {
error
};
},
check: async () => {
if (status === 'unauthenticated') {
return {
authenticated: false,
redirectTo: '/login'
};
}

return {
authenticated: true
};
},
getPermissions: async () => {
return null;
},
getIdentity: async () => {
if (data?.user) {
const { user } = data;
return {
name: user.name,
avatar: user.image
};
}

return null;
}
};
const authProvider: AuthProvider = {
login: async () => {
signIn('keycloak', {
callbackUrl: to ? to.toString() : '/',
redirect: true
});

return {
success: true
};
},
logout: async () => {
signOut({
redirect: true,
callbackUrl: '/login'
});

return {
success: true
};
},
onError: async (error) => {
if (error.response?.status === 401) {
return {
logout: true
};
}

return {
error
};
},
check: async () => {
if (status === 'unauthenticated') {
return {
authenticated: false,
redirectTo: '/login'
};
}

return {
authenticated: true
};
},
getPermissions: async () => {
return null;
},
getIdentity: async () => {
if (data?.user) {
const { user } = data;
return {
name: user.name,
avatar: user.image
};
}

return null;
}
};
I am also utilizing a simple-rest server.
'use client';

import dataProviderSimpleRest from '@refinedev/simple-rest';

const API_URL = 'http://localhost:3000/api';

export const dataProvider = dataProviderSimpleRest(API_URL);
'use client';

import dataProviderSimpleRest from '@refinedev/simple-rest';

const API_URL = 'http://localhost:3000/api';

export const dataProvider = dataProviderSimpleRest(API_URL);
Where does it store the auth token? And how can i pass this auth token in my simple-rest provider?
5 replies