#NEWLINE# def GetAuth1Token( ) : #NEWLINE# #INDENT# 'Returns an Auth1Token for use with server authentication.' #NEWLINE# if AUTH1_TOKEN : #NEWLINE# #INDENT# return AUTH1_TOKEN #NEWLINE# #UNINDENT# if ( not OBJC_OK ) : #NEWLINE# #INDENT# logging . error ( 'Objective-C bindings not available.' ) #NEWLINE# return None #NEWLINE# #UNINDENT# pref_value = Foundation . CFPreferencesCopyAppValue ( 'AdditionalHttpHeaders' , 'ManagedInstalls' ) #NEWLINE# if ( pref_value is None ) : #NEWLINE# #INDENT# logging . error ( 'GetAuth1Token(): AdditionalHttpHeaders not present.' ) #NEWLINE# return None #NEWLINE# #UNINDENT# header = 'Cookie: Auth1Token=' #NEWLINE# for h in pref_value : #NEWLINE# #INDENT# if h . startswith ( header ) : #NEWLINE# #INDENT# logging . debug ( 'GetAuth1Token(): found %s' , h ) #NEWLINE# token = h [ len ( header ) : ] #NEWLINE# if ( token . find ( ';' ) > ( - 1 ) ) : #NEWLINE# #INDENT# token = token [ 0 : token . find ( ';' ) ] #NEWLINE# #UNINDENT# token = str ( token ) #NEWLINE# return token #NEWLINE# #UNINDENT# #UNINDENT# logging . error ( 'GetAuth1Token(): AdditionalHttpHeaders lacks a token.' ) #NEWLINE# return None