msgraph-typescript-typings icon indicating copy to clipboard operation
msgraph-typescript-typings copied to clipboard

No interfaces for authentication responses

Open luzlab opened this issue 5 years ago • 5 comments

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 avatar Jun 12 '19 20:06 luzlab

@luzlab I couldn't get it, you explain the scenario more elaborately ?

muthurathinam avatar Jun 18 '19 03:06 muthurathinam

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

luzlab avatar Jun 26 '19 17:06 luzlab

I would also like this, but I was under the impression that the OAuth API is separate from the Graph API, no?

BovineEnthusiast avatar May 15 '20 18:05 BovineEnthusiast

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.

thesauri avatar Jun 12 '20 12:06 thesauri

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.

ddyett avatar Jun 12 '20 17:06 ddyett