How setup credentials like cookie, certificate into Typescript clients #4712
Unanswered
ChristopheNewbie
asked this question in
Q&A
Replies: 5 comments 7 replies
-
Thanks for using kiota and for reaching out. |
Beta Was this translation helpful? Give feedback.
1 reply
This comment has been minimized.
This comment has been minimized.
This comment was marked as spam.
This comment was marked as spam.
-
@baywet ? Someone else ? Can I provide more informations ? Is something not clear ? |
Beta Was this translation helpful? Give feedback.
6 replies
-
For the record, I managed to make it work based on #4712 (reply in thread) Here is a complete example: import { AnonymousAuthenticationProvider } from '@microsoft/kiota-abstractions';
import { FetchRequestAdapter, KiotaClientFactory } from '@microsoft/kiota-http-fetchlibrary';
import { createClient } from './generated/client.js';
// API requires no authentication, so use the anonymous
// authentication provider
const authProvider = new AnonymousAuthenticationProvider();
// Define a custom fetch function to set the 'credentials' option.
// This function wraps the global fetch, but adds our required option.
const customFetch = (url: Parameters<typeof fetch>[0], init?: RequestInit) => fetch(url, {
...init,
credentials: 'include', // 'include' tells the browser to send cookies
});
const httpClient = KiotaClientFactory.create(customFetch);
const adapter = new FetchRequestAdapter(authProvider, undefined, undefined, httpClient);
adapter.baseUrl = 'http://localhost:3000';
export const client = createClient(adapter); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
Our team is brand new using Kiota. We generated Typescript clients.
We want to send cookies with our request. How can we set it up ? Or is it an other way ?
Using HttpClient, you just define it like that :
Thank you for the help 👍
Beta Was this translation helpful? Give feedback.
All reactions