Hello,
Is it possible to have a collection with only admin access, that i can fetch data from using basic auth with my admins credentials and the rest api?
Not entirely sure about using basic auth, but perhaps this might fit your need:
Simply create an API key for your admin user, and use the created api key to authenticate 🙂
So i would just do this:
const Users: CollectionConfig = {
slug: 'users',
admin: {
useAsTitle: 'name',
defaultColumns: ['name', 'email'],
},
access: {
read: admins,
create: anyone,
update: adminsAndUser,
delete: admins,
// admin: ({ req: { user } }) => checkRole(['admin'], user),
},
auth: {
useAPIKey: true,
},
fields: UserFields,
timestamps: true,
}
On my users config, and then i will be able to authenticate to all my collections, after checking the checkbox on the users page?
Yup
This will appear on a user, it will generate an API key
And here I use the Authorization header
And it allows me to create a new document entry
It works, thank you very much 🙂
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.