title: Outlook OAuth2 can't redirect to application
body: <p>I'm currently trying use the outlook mail service to obtain contacts/appointments and mails. However I've stumbled upon a problem.</p>
  <p>I'm using <a href="https://github.com/OAuthSwift/OAuthSwift" rel="nofollow noreferrer">OAuth2Swift</a> as library to make all my OAuth calls since I'm integrating multiple services.</p>
  <p>I created a <code>URL scheme</code>like described in their <code>README</code>
  <a href="https://i.stack.imgur.com/mBqsB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mBqsB.png" alt="enter image description here" /></a></p>
  <p>Then I created a <code>Constants</code> file which looks like this</p>
  <pre><code>struct Consumer {
      let consumerKey: String
      let consumerSecret: String
      let authorizeURL: String
      let accessTokenURL: String
      let responseType: String?
      let requestTokenURL: String?
  }
  
  let Outlook = Consumer(
      consumerKey: &quot;&quot;,
      consumerSecret: &quot;&quot;,
      authorizeURL: &quot;https://login.microsoftonline.com/common/oauth2/v2.0/authorize&quot;,
      accessTokenURL: &quot;https://login.microsoftonline.com/common/oauth2/v2.0/token&quot;,
      responseType: &quot;code&quot;,
      requestTokenURL: nil)
  </code></pre>
  <p>I created an application for outlook on <a href="https://apps.dev.microsoft.com" rel="nofollow noreferrer">https://apps.dev.microsoft.com</a><br />
  generated my key and secret and filled them in inside my application.</p>
  <p>I added the <code>mobile application</code> platform to my app. Which tells me to use the redirect URI <code>urn:ietf:wg:oauth:2.0:oob</code></p>
  <p>So my code to authorise looks like this</p>
  <pre><code>@IBAction func btn_Outlook(_ sender: Any) {
          let oauthOU = OAuth2Swift(
              consumerKey: Outlook.consumerKey,
              consumerSecret: Outlook.consumerSecret,
              authorizeUrl: Outlook.authorizeURL,
              accessTokenUrl: Outlook.accessTokenURL,
              responseType: Outlook.responseType!)
          
          oauthOU.authorizeURLHandler = SafariURLHandler(viewController: self, oauthSwift: oauthOU)
          oauthOU.authorize(
              withCallbackURL: &quot;urn:ietf:wg:oauth:2.0:oob&quot;,
              scope: &quot;https://outlook.office.com/Mail.ReadWrite https://outlook.office.com/Mail.Send https://outlook.office.com/Calendars.ReadWrite https://outlook.office.com/Contacts.ReadWrite https://outlook.office.com/Tasks.ReadWrite&quot;,
              state: state,
              success: { credential, response, parameters in
                  print(&quot;logged in with \(credential), with response \(response) and parameters \(parameters)&quot;)},
              failure: { error in
                  print(&quot;error occured \(error.localizedDescription)&quot;)
              }
              )
          }
  </code></pre>
  <p>when I run the code I first get a screen to enter my mail/password. When I enter my mail it will redirect me to a different page/portal where I can enter my password. When I've entered my password it will show me the permissions screen.</p>
  <p><a href="https://i.stack.imgur.com/aF9Z4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aF9Z4.png" alt="enter image description here" /></a></p>
  <p>as soon as I hit <code>yes</code> it will give me an error saying &quot;Safari cannot open the page because the address is invalid.&quot; I'm pretty sure this has to do with the <code>redirect URI</code> but I'm not sure what to do to actually fix this.</p>
  <p>I'm hoping someone is able to help me out with this!</p>