-
Notifications
You must be signed in to change notification settings - Fork 232
Introducing Kiota Authentication #590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
baywet
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for starting this! It's great to see things starting to line up! Lots of work ahead but it's starting to take shape! Two minor comments on my side.
| * @callback - The anonymous callback function which takes a single param | ||
| */ | ||
| export type AuthProvider = (done: AuthProviderCallback) => void; | ||
| export interface AuthProviderCallback { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the value of this interface since we already have access token provider in kiota? (or will have soon at least)
| * To get the access token | ||
| * @returns The promise that resolves to an access token | ||
| */ | ||
| public getAuthorizationToken(): Promise<string> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note, should probably be using the allowed host validator and check for https
| * @returns The promise that resolves to an access token | ||
| */ | ||
| public async getAuthorizationToken(url: string): Promise<string> { | ||
| if (!url || !this.allowedHostsValidator.isUrlHostValid(url)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check for https
src/GraphRequest.ts
Outdated
| this.updateRequestOptions(options); | ||
| const customHosts = this.config?.customHosts; | ||
| const customHosts = this.config?.customHosts; | ||
| const requestInfo = new RequestInformation(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assuming we're manipulating a BaseBearerTokenAuthenticationProvider and this provides a property for the access token provider, you shouldn't have to instantiate a request information at all for arbitrary requests
| * @public | ||
| * @constructor | ||
| * Creates an instance of AuthenticationHandler | ||
| * @param {AuthenticationProvider} authenticationProvider - The authentication provider for the authentication handler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
param name and description needs to be updated
| const scopes = ["User.Read", "Mail.Send"]; | ||
|
|
||
| const graphClient = Client.init({ | ||
| authenticationTokenProvider: new AzureIdentityAuthenticationProvider(deviceCodeCredentials, scopes), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| authenticationTokenProvider: new AzureIdentityAuthenticationProvider(deviceCodeCredentials, scopes), | |
| authenticationProvider: new AzureIdentityAuthenticationProvider(deviceCodeCredentials, scopes), |
|
|
||
| ```Shell | ||
| npm install @microsoft/msgraph-sdk-javascript-core --save | ||
| npm install @microsoft/msgraph-sdk-javascript-types --save-dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we still going to chip the type separately at this point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My feeling tells me a core user should have access to the Types. Especially with the work we are doing with the api() method that would reuse the same pattern than the rest of our chained factories. I think a user should be able to benefit from our types without having to download all of our package.
| const scopes = ["User.Read", "Mail.Send"]; | ||
|
|
||
| const graphClient = Client.init({ | ||
| authenticationTokenProvider: new AzureIdentityAuthenticationProvider(deviceCodeCredentials, scopes), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| authenticationTokenProvider: new AzureIdentityAuthenticationProvider(deviceCodeCredentials, scopes), | |
| authenticationProvider: new AzureIdentityAuthenticationProvider(deviceCodeCredentials, scopes), |
|
isn't this one superseded by #712 at this point? lots of duplicate changes |
|
The changes here are contains in #712 |
This PR is WIP.
client.api("")request using Kiota Authentication.Graph.IAuthenticationProviderand modified code to align withKiota.IAuthenticationProviderandKiota.IAccessTokenProvider.SimpleAuthenticationProvideras suggested by @sebastienlevert aligning with MGT SimpleProvider. We could move this to Kiota too.https://github.com/microsoftgraph/microsoft-graph-toolkit/blob/ec1a5bf8cbe0f76f4aea9da8ad425b144f5c6572/packages/mgt-element/src/providers/SimpleProvider.ts#L19
fixes #536