Работающий ADAL код ломается в Oreo 8.0
Я использую Microsoft.IdentityModel.Clients.ActiveDirectory для аутентификации
Обновлен Android до 8.0, тот же код все еще отлично работает в iOS
На Android единственное изменение, которое я должен был сделать, было в Custom Renderer, необходимом для обработки входа в AAD, когда я получил сообщение "устарел", поэтому я добавил это
Это пользовательский рендерер страниц для Android
public AuthRenderer(Context context) : base(context)
{
}
Views.Auth page;
protected override void OnElementChanged(ElementChangedEventArgs<Page> e)
{
System.Console.WriteLine("Debug: Loaded the page renderer");
base.OnElementChanged(e);
page = e.NewElement as Views.Auth;
var activity = this.Context as Activity;
page.platformParameters = new PlatformParameters(activity);
page.platformParameters.ToString();
System.Console.WriteLine("Platform P " + page.platformParameters.ToString());
}
Это фрагмент кода, используемый для получения токена
authContext = new AuthenticationContext(authority);
PlatformParameters p = new PlatformParameters(PromptBehavior.Auto, hwnd);
AuthenticationResult result = null;
result = await authContext.AcquireTokenAsync(todoListResourceId, clientId, redirectURI, p);
Resource = https://[mywebsite].azurewebsites.net/api/Timekeeper
тем не менее, код теперь просто не может вернуть токен так, как это было в 7.1 и по-прежнему в iOS
Приложил вывод из окна в Visual Studio, если кто-то может, пожалуйста, просмотреть и посмотреть, если что-нибудь выскакивает?
[] 2018-03-01T14:22:11.6337440Z: 03e9fa3d-adae-45e8-bb97-0259fab9222b - LoggerBase.cs: Loading from cache.
[] 2018-03-01T14:22:11.6597470Z: 03e9fa3d-adae-45e8-bb97-0259fab9222b - LoggerBase.cs: Looking up cache for a token...
[] 2018-03-01T14:22:11.6752130Z: 03e9fa3d-adae-45e8-bb97-0259fab9222b - LoggerBase.cs: No matching token was found in the cache
[zygote] Do partial code cache collection, code=23KB, data=30KB
[zygote] After code cache collection, code=23KB, data=30KB
[zygote] Increasing code cache capacity to 128KB
[WebViewFactory] Loading com.android.chrome version 58.0.3029.125 (code 303012512)
[cr_LibraryLoader] Time to load native libraries: 5 ms (timestamps 5331-5336)
[chromium] [INFO:library_loader_hooks.cc(140)] Chromium logging enabled: level = 0, default verbosity = 0
[cr_LibraryLoader] Expected native library version number
"58.0.3029.125", actual native library version number "58.0.3029.125"
[cr_BrowserStartup] Initializing chromium process, singleProcess=false
[cr_ChildProcLauncher] Create a new ChildConnectionAllocator with package name = com.android.chrome, inSandbox = true
[zygote] Do partial code cache collection, code=25KB, data=46KB
[zygote] After code cache collection, code=25KB, data=46KB
[zygote] Increasing code cache capacity to 256KB
[zygote] JIT allocated 56KB for compiled code of void android.view.View.<init>(android.content.Context, android.util.AttributeSet, int, int)
[] HostConnection::get() New Host Connection established 0x8c67c780, tid 999
[EGL_emulation] eglCreateContext: 0x8c607bc0: maj 2 min 0 rcv 2
[EGL_emulation] eglMakeCurrent: 0x8c607bc0: ver 2 0 (tinfo 0x8b45c550)
[] 2018-03-01T14:22:12.1121650Z: 00000000-0000-0000-0000-000000000000 - LoggerBase.cs: UserAgent:Mozilla/5.0 (Linux; Android 8.0.0; Android SDK built for x86 Build/OSR1.170901.056; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/58.0.3029.125 Mobile Safari/537.36 PKeyAuth/1.0
[BluetoothAdapter] Bluetooth binder is null
[cr_LibraryLoader] Using linker:org.chromium.base.library_loader.ModernLinker
[zygote] Attempt to remove non-JNI local reference, dumping thread
[EGL_emulation] eglMakeCurrent: 0x8dc4e2e0: ver 2 0 (tinfo 0x8db2eb70)
[] HostConnection::get() New Host Connection established 0x88feb980, tid 1118
[EGL_emulation] eglCreateContext: 0x88fec2a0: maj 2 min 0 rcv 2
[EGL_emulation] eglMakeCurrent: 0x88fec2a0: ver 2 0 (tinfo 0x88fcddd0)
[VideoCapabilities] Unsupported profile 4 for video/mp4v-es
[cr_MediaCodecUtil] HW encoder for video/avc is not available on this device.
[cr_MediaCodecUtil] HW encoder for video/avc is not available on this device.
[chromium] [ERROR:gl_surface_egl.cc(264)] eglChooseConfig failed with error EGL_SUCCESS
[EGL_emulation] eglCreateContext: 0x88fed080: maj 2 min 0 rcv 2
[EGL_emulation] eglMakeCurrent: 0x88fed080: ver 2 0 (tinfo 0x88fcddd0)
[zygote] Attempt to remove non-JNI local reference, dumping thread
[Mono] Assembly Ref addref Xamarin.Forms.Platform.Android[0xa55843c0] -> System.Xml[0xb0be9640]: 6
[cr_Ime] updateState: type [0->4], flags [64], show [false],
[zygote] Attempt to remove non-JNI local reference, dumping thread
[chatty] uid=10093(u0_a93) com.microlise.GeoFenceLocator identical 18 lines
[zygote] Attempt to remove non-JNI local reference, dumping thread
[cr_Ime] updateState: type [4->4], flags [64], show [true],
[cr_Ime] updateState: type [4->4], flags [64], show [false],
[cr_Ime] updateState: type [4->4], flags [64], show [false],
[chatty] uid=10093(u0_a93) com.microlise.GeoFenceLocator identical 5 lines
[cr_Ime] updateState: type [4->4], flags [64], show [false],
[zygote] Do full code cache collection, code=121KB, data=82KB
[zygote] After code cache collection, code=121KB, data=54KB
[zygote] Attempt to remove non-JNI local reference, dumping thread
[zygote] Attempt to remove non-JNI local reference, dumping thread
1 ответ
Та же проблема здесь, точно такая же, за исключением того, что у меня много неудач в поиске токена в кеше
05-02 11:48:14.900 I/ (22473): 2018-05-02T09:48:14.9002390Z: 18184aeb-e84c-4942-8b09-c1578be3e24f - LoggerBase.cs: === Token Acquisition started:
05-02 11:48:14.900 I/ (22473): CacheType: null
05-02 11:48:14.900 I/ (22473): Authentication Target: User
05-02 11:48:14.900 I/ (22473): , Authority Host: login.microsoftonline.com
05-02 11:48:14.901 V/ (22473): 2018-05-02T09:48:14.9014030Z: 18184aeb-e84c-4942-8b09-c1578be3e24f - LoggerBase.cs: Loading from cache.
05-02 11:48:14.903 V/ (22473): 2018-05-02T09:48:14.9031280Z: 18184aeb-e84c-4942-8b09-c1578be3e24f - LoggerBase.cs: Looking up cache for a token...
05-02 11:48:14.904 I/ (22473): 2018-05-02T09:48:14.9037160Z: 18184aeb-e84c-4942-8b09-c1578be3e24f - LoggerBase.cs: No matching token was found in the cache
05-02 11:48:14.904 V/ (22473): 2018-05-02T09:48:14.9042730Z: 18184aeb-e84c-4942-8b09-c1578be3e24f - LoggerBase.cs: Looking up cache for a token...
05-02 11:48:14.907 I/ (22473): 2018-05-02T09:48:14.9047280Z: 18184aeb-e84c-4942-8b09-c1578be3e24f - LoggerBase.cs: No matching token was found in the cache
05-02 11:48:14.907 V/ (22473): 2018-05-02T09:48:14.9074180Z: 18184aeb-e84c-4942-8b09-c1578be3e24f - LoggerBase.cs: Looking up cache for a token...
05-02 11:48:14.908 I/ (22473): 2018-05-02T09:48:14.9078860Z: 18184aeb-e84c-4942-8b09-c1578be3e24f - LoggerBase.cs: No matching token was found in the cache
05-02 11:48:14.908 V/ (22473): 2018-05-02T09:48:14.9085600Z: 18184aeb-e84c-4942-8b09-c1578be3e24f - LoggerBase.cs: Looking up cache for a token...
05-02 11:48:14.909 I/ (22473): 2018-05-02T09:48:14.9091330Z: 18184aeb-e84c-4942-8b09-c1578be3e24f - LoggerBase.cs: No matching token was found in the cache
05-02 11:48:14.910 V/ (22473): 2018-05-02T09:48:14.9099840Z: 18184aeb-e84c-4942-8b09-c1578be3e24f - LoggerBase.cs: Looking up cache for a token...
05-02 11:48:14.911 I/ (22473): 2018-05-02T09:48:14.9107730Z: 18184aeb-e84c-4942-8b09-c1578be3e24f - LoggerBase.cs: No matching token was found in the cache
05-02 11:48:14.912 V/ (22473): 2018-05-02T09:48:14.9117930Z: 18184aeb-e84c-4942-8b09-c1578be3e24f - LoggerBase.cs: Looking up cache for a token...
05-02 11:48:14.913 I/ (22473): 2018-05-02T09:48:14.9125770Z: 18184aeb-e84c-4942-8b09-c1578be3e24f - LoggerBase.cs: No matching token was found in the cache
После долгих исследований я нашел свое решение. ADAL в проекте UWP работал, то же самое на iOS... Так что проблема должна быть на Android...
В файле MainActivity.cs проекта android я бездумно закомментировал приведенную ниже строку из переопределенного метода OnActivityResult.
AuthenticationAgentContinuationHelper.SetAuthenticationAgentContinuationEventArgs(requestCode, resultCode, intent);
Итак, весь код этого метода теперь будет выглядеть так:
protected override void OnActivityResult(int requestCode, Result resultCode, Intent intent)
{
base.OnActivityResult(requestCode, resultCode, intent);
AuthenticationAgentContinuationHelper.SetAuthenticationAgentContinuationEventArgs(requestCode, resultCode, intent);
}
Надеюсь, это поможет кому-то!