Entra и Mip Errror с использованием c# .accessdeniedexception: служба не приняла токен Auth. Испытание:['']C#

Место общения программистов C#
Ответить Пред. темаСлед. тема
Anonymous
 Entra и Mip Errror с использованием c# .accessdeniedexception: служба не приняла токен Auth. Испытание:['']

Сообщение Anonymous »

Вот сообщение об ошибке, которое я получаю, мы используем логин и пароль для получения токена Auth, просто не знаете, какие разрешения нам нужны. Задача: [''] httprequest.id = {e0c61208-d90f-49ff-83e0-2a17f8d3db9a}, correlationid = 0a882288-d5e3-4b7a-812b-a5dc5a779271, correlationid.description = policeprof at atiolprpoprof = polidy Emailsdk.program. 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;

}


Подробнее здесь: https://stackoverflow.com/questions/787 ... e-didnt-ac
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «C#»