Closed naelob closed 9 months ago
Hi @naelob, This is most likely caused because you're initializing your client with an anonymous authentication provider when from reading the quick start of the API this API seems to require two authentication related headers:
Let us know if you have further questions.
Hi @naelob, This is most likely caused because you're initializing your client with an anonymous authentication provider when from reading the quick start of the API this API seems to require two authentication related headers:
- the API key generated from their portal
- the connection_token I recommend that you implement the authentication provider interface to set those two headers on the request information and pass an instance of that implementation to the request adapter.
Let us know if you have further questions.
Thank you for the answer. I actually built the api so only the api key is mandatory on certain routes (the / route is not protected). Connection token is used only at certain routes too.
I still decided to check to implement a provider and found this https://learn.microsoft.com/en-us/openapi/kiota/authentication?tabs=typescript#:~:text=In%20getAuthorizationToken%2C%20the%20url%20parameter%20is%20the%20URL%20of%20the%20abstract%20request%20to%20be%20executed.%20The%20return%20value%20is%20a%20Promise%20that%20holds%20the%20access%20token%2C%20or%20null%20if%20the%20request%20could/should%20not%20be%20authenticated.
I don't get it, I may have missed something but I'd like to use it like const authProvider = new BaseBearerTokenAuthenticationProvider('my_api_key');
.
I have to build a specific url route so AccessTokenProvider
can retrieve it through this url with getAuthorizationToken
?
yes, the way this is designed:
BaseBearerTokenAuthenticationProvider
in a new authentication provider class, this will pass your access token provider to the base.You can check how AzureIdentity authentication and access providers work (same repo) to get a better idea.
AzureIdentity Thanks !
I still face the issue:
right, from reading the docs, I think this is only half the work here. You also need to set the connection_token request header.
Since this is really specific to this API, I suggest you :
With all those pieces in place, this should solve your authorization issue. If that still doesn't work, please get in touch with the API provider to get clarity on the authentication requirements
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.
Hey !
I've been stucked with an issue just after running
npx ts-node index.ts
(followed this guide https://learn.microsoft.com/en-us/openapi/kiota/tutorials/typescript-azure?tabs=portal)I get the error: Error: Content type text/html does not have a factory registered to be parsed
Here is my repo : https://github.com/naelob/test-sdk
Steps to reproduce:
kiota generate -l typescript -d api-doc.json -c Client -o ./client
npx ts-node index.ts
(of course I manually tried to use the sdk client by creating an index.ts file)Thanks !
@baywet