msgraph-typescript-typings
msgraph-typescript-typings copied to clipboard
No interfaces for authentication responses
I noticed there no interfaces for responses when authenticating into the Graph API. I could work on a PR if this isn't on the roadmap. AB#7039
@luzlab I couldn't get it, you explain the scenario more elaborately ?
When I get an [access token from the identity platform endpoint, I couldn't find a Typescript definition for the response.
It's minor, In my code, I used an inline type assertion to handle this.
const options = {
form: payload,
json: true,
method: 'POST',
uri: `https://login.microsoftonline.com/${tenantId}/oauth2/v2.0/token`,
};
const { access_token, expires_in } =(await request(options)) as { access_token: String; expires_in: Number };
I was thinking that it would be easy to add a type for the response...
enum TokenType {
bearer,
}
interface Authorization {
token_type: TokenType
expires_in: number
access_token: string
}
// ... so I could do this instead
const { access_token, expires_in } =(await request(options)) as MicrosoftGraph.Authorization
I would also like this, but I was under the impression that the OAuth API is separate from the Graph API, no?
I would also find this useful. Authorization is part of the flow in consuming the Graph API and the token is used in subsequent calls.
if you are using msal as the ImplicitMSALAuthenticationProvider in the javascript SDK does, it does provide an AuthResponse interface. this project is about describing responses from the Graph API, and while it is a part of the flow in the javascript SDK the SDK doesn't itself handle the authentication.