title: Getting CloudKit CKAsset URL?
body: <p>I'd like to share a CloudKit asset in the public database with people who aren't using my app. From the CKAsset class, there's only a <code>fileURL</code> property, which points to a local file, so no URL given.</p>
  
  <p>On the documentation for CloudKit Web Services, however, <a href="https://developer.apple.com/library/ios/documentation/DataManagement/Conceptual/CloutKitWebServicesReference/RereferenceAssets/RereferenceAssets.html" rel="nofollow">there is a "referencing existing assets" request</a>, which <a href="https://developer.apple.com/library/ios/documentation/DataManagement/Conceptual/CloutKitWebServicesReference/Types/Types.html#//apple_ref/doc/uid/TP40015240-CH3-SW3" rel="nofollow">in its' response</a> gives a <code>downloadURL</code> to the asset file.</p>
  
  <p>Calling this from my app gives me a 421 status code, which is described <a href="https://developer.apple.com/library/ios/documentation/DataManagement/Conceptual/CloutKitWebServicesReference/ErrorCodes/ErrorCodes.html#//apple_ref/doc/uid/TP40015240-CH4-SW1" rel="nofollow">in documentation</a> as "AUTHENTICATION_REQUIRED", as it requires a <code>ckSession</code> parameter to be given, which is a "session identifier of an authenticated user". It also passes a <code>redirectURL</code>, where a user can type in their iCloud login, and then be re-directed back to the web application, now with a session identifier.</p>
  
  <p>Opening this URL inside the app didn't immediately return the session identifier, but instead expected the user to go through the login process in a browser, before receiving their session ID.</p>
  
  <p>This seems totally off-track, and the wrong thing to be doing. I'm certainly not going to make my users log in to iCloud through a web interface. The only thing missing for that CloudKit Web Services url is the session ID. Is there a way for me to get that using the CloudKit framework? Or is there another way for me to find out this file's URL?</p>