error 401 depends on API Key settings
-
Hi.
I have installed fusionauth on docker and I have written webhook that use FA API to update user data object.
I use default tenant and have created new application.
I have created new API Key and select /api/user for GET and PATCH that I use.
In this case I get error 401
But if I do not select endpoints (a super user key) then update is successfull.FA version [1.31.0]
-
Hiya,
Can you share your code that makes the update? Can you try allowing all the HTTP methods for the key on the
/api/user
endpoint, not just GET and PATCH? -
I tried with all HTTP methods enabled for /api/user only, and it update user successfully.
But if I tried only with GET and PATCH methods enabled for /api/user , I get 'statusCode=401'.
Here is codeimport { FusionAuthClient, UserRequest } from '@fusionauth/typescript-client' ... export class FusionAuthService { private fusionAuthClient: FusionAuthClient; constructor(private context: Context) { this.fusionAuthClient = new FusionAuthClient(context.config.fusionAuth.apiKey, context.config.fusionAuth.apiUrl); } ... public async updateUser(userId: string, userRequest: UserRequest ) { return this.fusionAuthClient.updateUser(userId, userRequest) .then(clientResponse => { logger.info("User:", JSON.stringify(clientResponse.response.user, null, 2)); }).catch(logger.error); }
here is invocation of updateUser method that happens on 'user.registration.create' event
if (user) { const patchBody = { user: { email: event.user.email, data: { userId: user.id } }, } await this.fusionAuthService.updateUser(event.user.id, patchBody); }
Now I understand that I use updateUser method and I don't know what kind of HTTP request it used.
I have found patchUser and with it get success.Thanks for your help.