sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

@microsoft/sp-http AadTokenProvider typings in dist/index-internal.d.ts do not match with the typings in the lib/oauthTokenProvider folder

Open henkterharmsel opened this issue 8 years ago • 4 comments

Category

  • [ ] Question
  • [ ] Typo
  • [x ] Bug
  • [ ] Additional article idea

Expected or Desired Behavior

Because of this issue I wanted to use our own azure ad app registration. To do this we created a new AadHttpClient (instead of using aadHttpClientFactory.getClient) with our own servicePrincipalId. Therefore we also needed to create our own AadTokenProvider. This is were the bug occurs.

let configuration: IAadTokenProviderConfiguration = {
    aadInstanceUrl: "https://login.windows.net",
    aadTenantId: "<tenant id>",
    aadUserId: "<user id>",
    redirectUri: "https://<our tenant>.sharepoint.com/_forms/spfxsinglesignon.aspx",
    servicePrincipalId: "<own id>"
};
let options: IAadHttpClientOptions = {
    tokenProvider: new MyAadTokenProvider(configuration),
    configuration: configuration
};
let serviceScope = this.props.context.serviceScope.getParent();
let client: AadHttpClient = new AadHttpClient(serviceScope, "https://graph.microsoft.com", options);
export class MyAadTokenProvider extends AadTokenProvider {
    constructor(configuration: IAadTokenProviderConfiguration) {
        super(configuration);
    }

    public getToken(resourceEndpoint: string, configuration?: IAadTokenProviderConfiguration): Promise<string> {
        console.log(resourceEndpoint, configuration);
        return super.getToken(resourceEndpoint);
    }
}

Observed Behavior

The constructor of the the AadTokenProvider used in @microsoft/sp-http lib folder (which is also used in the browser) needs the IAadTokenProviderConfiguration as an mandatory parameter, while the AadTokenProvider described in the @microsoft/sp-http dest/index-internal.d.ts file does not. The code breaks in the browser when I use the index-internal typings and it won't compile when I use the typings from the lib folder.

That said, when I correct the typings in the index-internal.d.ts myself, the code is working perfectly.

Steps to Reproduce

install the latest 1.6.0 spfx packages (including the @microsoft/sp-http package)

henkterharmsel avatar Oct 17 '18 08:10 henkterharmsel

Do you have other config except the default template?

Seiyasu avatar Oct 18 '18 06:10 Seiyasu

Yes, I am overriding the default configuration this way, because I want to use another "servicePrincipalId".

henkterharmsel avatar Oct 18 '18 07:10 henkterharmsel

Hi @pkmelee337,

I'm afraid that this is by design. Using a custom configuration isn't supported, so this behavior was removed from the typings.

ghost avatar Dec 17 '18 21:12 ghost

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

msft-github-bot avatar Jan 26 '20 06:01 msft-github-bot