title: ADAL Authentication Requires Device managed
body: <p>I've setup a Demo app for ADAL Authentication. Our company request the InTune app installed: <a href="https://itunes.apple.com/us/app/intune-company-portal/id719171358?mt=8" rel="nofollow noreferrer">https://itunes.apple.com/us/app/intune-company-portal/id719171358?mt=8</a></p>
  
  <p>After the installation and the setup of InTune, I've installed the demo with ADAL that i've developed:</p>
  
  <ol>
  <li><p>added ADAL as Pod Library</p></li>
  <li><p>added redirect URI inside my Azure Portal (<a href="https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps" rel="nofollow noreferrer">https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps</a>) (one with schema://bundle_id and one with msauth://code/schema%3A%2F%2Fbundle_id)</p></li>
  <li><p>added to app's info.plist:</p>
  
  <pre><code>&lt;key&gt;LSApplicationQueriesSchemes&lt;/key&gt;
  &lt;array&gt;
      &lt;string&gt;msauth&lt;/string&gt;
  &lt;/array&gt;
  </code></pre></li>
  </ol>
  
  <p>4.added to app's info.plist</p>
  
  <pre><code>&lt;key&gt;CFBundleURLTypes&lt;/key&gt;
  &lt;array&gt;
      &lt;dict&gt;
          &lt;key&gt;CFBundleTypeRole&lt;/key&gt;
          &lt;string&gt;Editor&lt;/string&gt;
          &lt;key&gt;CFBundleURLName&lt;/key&gt;
          &lt;string&gt;bundle_id&lt;/string&gt;
          &lt;key&gt;CFBundleURLSchemes&lt;/key&gt;
          &lt;array&gt;
              &lt;string&gt;schema&lt;/string&gt;
          &lt;/array&gt;
      &lt;/dict&gt;
  &lt;/array&gt;
  </code></pre>
  
  <ol start="5">
  <li><p>added <code>[_authContext setCredentialsType:AD_CREDENTIALS_AUTO];</code> to use inTune App Portal for broker auth.</p></li>
  <li><p>create the authentication with: </p>
  
  <pre><code>ADAuthenticationError *error = nil;
   _authContext = [ADAuthenticationContext authenticationContextWithAuthority:@"https://login.microsoftonline.com/common" error:&amp;error];  
  [_authContext setCredentialsType:AD_CREDENTIALS_AUTO];
  
  [_authContext acquireTokenWithResource:@"https://graph.microsoft.com"
                            clientId:@"my_client_id"                          // Comes from App Portal
                         redirectUri:[NSURL URLWithString:@"schema://bundle_id"] // Comes from App Portal
                     completionBlock:^(ADAuthenticationResult *result)
  {
     NSLog(result.accessToken);
   }];
  </code></pre></li>
  </ol>
  
  <p>Application will correctly prompt microsoft authentication to the user, that is redirected on microsofth authentication on the company page, but after the Authentication, this is the result:</p>
  
  <p><a href="https://i.stack.imgur.com/aI5Gm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aI5Gm.png" alt="enter image description here"></a></p>