Here is the error message I get, we are using a login and password to get the auth token
just not sure what permissions we need.
“Microsoft.InformationProtection.Exceptions.AccessDeniedException: The service didn’t accept the auth token. Challenge:[”] HttpRequest.Id={E0C61208-D90F-49FF-83E0-2A17F8D3DB9A}, CorrelationId=0a882288-d5e3-4b7a-812b-a5dc5a779271, CorrelationId.Description=PolicyProfile
at EmailSDK.Program.<>c__DisplayClass2_0.<b__1>d.MoveNext() in C:UsersDaHackersourcereposEmailSDKProgram.cs:line 56″
here is the code I have it is from MS’s quick guide
MIP.Initialize(MipComponent.File);
// Create ApplicationInfo, setting the clientID from Microsoft Entra App Registration as the ApplicationId.
ApplicationInfo appInfo = new ApplicationInfo()
{
ApplicationId = clientId,
ApplicationName = appName,
ApplicationVersion = "1.0.0"
};
// Instantiate the AuthDelegateImpl object, passing in AppInfo.
AuthDelegateImplementation authDelegate = new AuthDelegateImplementation(appInfo);
// Create MipConfiguration Object
MipConfiguration mipConfiguration = new MipConfiguration(appInfo, "mip_data", LogLevel.Trace ,false);
// Create MipContext using Configuration
using (MipContext mipContext = MIP.CreateMipContext(mipConfiguration))
{
// Initialize and instantiate the File Profile.
// Create the FileProfileSettings object.
// Initialize file profile settings to create/use local state.
FileProfileSettings profileSettings = new FileProfileSettings(mipContext,CacheStorageType.OnDiskEncrypted,
new ConsentDelegateImplementation());
// Load the Profile async and wait for the result.
IFileProfile fileProfile = Task.Run(async () => await MIP.LoadFileProfileAsync(profileSettings)).Result;
// Create a FileEngineSettings object, then use that to add an engine to the profile.
// This pattern sets the engine ID to [email protected], then sets the identity used to create the engine.
FileEngineSettings engineSettings = new FileEngineSettings("[email protected]", authDelegate, "", "en-US");
engineSettings.Identity = new Identity([email protected]);
IFileEngine fileEngine = null;
try
{
fileEngine = Task.Run(async () => await fileProfile.AddEngineAsync(engineSettings)).Result;
}
catch (Exception ex)
{
// Application Shutdown
// handler = null; // This will be used in later quick starts.
fileEngine = null;
fileProfile = null;
mipContext.ShutDown();
}
public AuthDelegateImplementation(ApplicationInfo appInfo)
{
_appInfo = appInfo;
}
public string AcquireToken(Identity identity, string authority, string resource, string claims)
{
authority = https://graph.microsoft.com/.default;
var authorityUri = new Uri(authority);
authority = String.Format([https://%7b0%7d/%7b1%7d]https://{0}/{1}, authorityUri.Host, "10462954-a52f-469d-9f83-8ac832d15e78");
_app = PublicClientApplicationBuilder.Create(_appInfo.ApplicationId).WithTenantId("10462954-a52f-469d-9f83-8ac832d15e78").Build();
var accounts = (_app.GetAccountsAsync()).GetAwaiter().GetResult();
string[] scopes = new[] { "User.Read.All" };
// string[] scopes = new[] { "Files.ReadWrite.All" };
var result = _app.AcquireTokenByUsernamePassword(scopes, "UserEmail:[email protected]", "Password: LetMeIn")
.ExecuteAsync().ConfigureAwait(false).GetAwaiter().GetResult();
return result.AccessToken;
}
1