Forum Discussion
ktchoumak
Jul 14, 2021Copper Contributor
How call to register printer with using provider is not calling popup dialog for Azure Login?
I have a client app where I can get berier token and pass it to service to Register printer. But how to register printer without using delegating provider? private static IAuthenticationPr...
Saurabh_Bansal
Microsoft
Jul 26, 2021ktchoumak - to register a printer we need it to be done explicitly by a printer admin action - thats why there you need the delegated token. Please note, if you are registering multiple printers at the same time and session length exceeds the expiry time of the token (typically one hour), then you can refresh the token without requiring the user to login.
If there is a strong scenario where you absolutely need application token, then I recommend filing a feature request at https://aka.ms/UPIdeas. Please explain your scenario in detail.
Thanks,
Saurabh
ktchoumak
Jul 26, 2021Copper Contributor
Thanks for answer - I found solution: use custom provider:
public class myProvider : Microsoft.Graph.IAuthenticationProvider
{
string Token { get; set; }
public myProvider (string bearerToken)
{
Token = bearerToken;
}
public Task AuthenticateRequestAsync(HttpRequestMessage request)
{
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Token);
return Task.FromResult(false);
}
}
public class myProvider : Microsoft.Graph.IAuthenticationProvider
{
string Token { get; set; }
public myProvider (string bearerToken)
{
Token = bearerToken;
}
public Task AuthenticateRequestAsync(HttpRequestMessage request)
{
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Token);
return Task.FromResult(false);
}
}