title: Implementing Oauth2.0 flow in IOS
body: <p>I am writing an IOS SDK and implementing oauth2.0 flow.</p>
  
  <p>I have the following oauth2.0 flow in the IOS SDK to allow developers to get control of my users' accounts:</p>
  
  <ul>
  <li>Open up webview with mysite/oauth2.0 as url</li>
  <li>User logs in/registers.</li>
  <li>Mysite.com redirects to special url with a code or error in the query string.</li>
  <li>Webview (via the shouldStartLoadWithRequest function) recognizes special url and closes itself.</li>
  </ul>
  
  <p>It then passes the code to the parent controller's delegate function. </p>
  
  <pre><code>[self.delegate processOauth2.0Code: code]
  </code></pre>
  
  <p>If there is an error (maybe user denied the oauth2.0), it creates NSError object and sends the NSError object to a separate delegate function)</p>
  
  <pre><code>[self.delegate processOAuth2.0Error: error]
  </code></pre>
  
  <ul>
  <li>Parent controller function then sends the code to a web server</li>
  <li>Web server uses the code with their application key to make an api call to my site to retrieve access token.</li>
  </ul>
  
  <p>Is that how such Oauth2.0 flows are designed in a mobile app?</p>
  
  <p>Do you guys have any advice for me on improving the design?</p>
  
  <p>Is it normal to have two delegate functions for code and error?</p>