Skip to content

Create a context dynamically by Url, not predefined in PnpCoreOptions.Sites #1627

Answered by pschaeflein
lgadola asked this question in Q&A
Discussion options

You must be logged in to vote

From the readme

If you prefer to create a PnPContext by specifying the URL you need in code or you want to be able to easily switch between authentication providers then below sample shows how to so. This snippet works without an configuration file, all you need to do is add the needed authentication provider configuration(s) and then later on in your code acquire the needed authentication providers via the IAuthenticationProviderFactory. Once you have your authentication provider you can use it in the Create methods on the context factory:

using (var scope = host.Services.CreateScope())
{
    var pnpContextFactory = scope.ServiceProvider.GetRequiredService<IPnPContextFactory>();
    var 

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@lgadola
Comment options

Answer selected by lgadola
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants