Open raclettierer opened 1 year ago
@raclettierer , thanks for raising this. We indeed did not test with the v5 Graph SDK.
This worked for me: `public class GraphTokenProvider : IAccessTokenProvider { private readonly PnPContext _pnpContext; public GraphTokenProvider(PnPContext context) { _pnpContext = context; AllowedHostsValidator = new AllowedHostsValidator(); }
public AllowedHostsValidator AllowedHostsValidator { get; }
public Task<string> GetAuthorizationTokenAsync(Uri uri, Dictionary<string, object>? additionalAuthenticationContext = null, CancellationToken cancellationToken = default)
{
return _pnpContext.AuthenticationProvider.GetAccessTokenAsync(new Uri("https://graph.microsoft.com"));
}
}`
var accessTokenProvider = new BaseBearerTokenAuthenticationProvider(new GraphTokenProvider(pnpContext)); var graphServiceClient = new GraphServiceClient(accessTokenProvider);
@TashunkoWitko : thanks for sharing this, I'll incorporate that in our docs.
Stumbled upon this issue after upgrading to Graph SDK v5 that obsoleted the DelegateAuthenticationProvider
.
Will the pnpContext.AuthenticationProvider.GetAccesstokenAsync
get a new token every time or does it handle token caching and lifetimes?
Category
Describe the bug
After updating the solution to the new microsoft graph library the interop code not working any more. The DelegateAuthenticationProvider is missing
Steps to reproduce
1) Update to Microsoft.Graph V 5.* 2) using code for interop: https://pnp.github.io/pnpcore/using-the-sdk/basics-graphsdk.html
Expected behavior
Environment details (development & target environment)
Additional context