Just in case this helps someone out there: here’s some code of mine that uses Apple’s grand central dispatch to login to DF but wait on the completion of the block before attempting to persist with the session_id. More elegant than some other options given the stateless nature of REST.