def signature_callback(request):
    currentDir = os.path.dirname(os.path.realpath(__file__))
    if os.path.exists(currentDir + '/../user_info.txt'):
        f = open(currentDir + '/../user_info.txt')
        lines = f.readlines()
        f.close()
        clientId = lines[0].replace("\r\n", "")
        privateKey = lines[1]

    if IsNotNull(request.json_body):
        jsonPostData = request.json_body
        envelopId = jsonPostData['SourceId']
        # Create signer object
        signer = GroupDocsRequestSigner(privateKey)
        # Create apiClient object
        apiClient = ApiClient(signer)
        # Create AsyncApi object
        signature = SignatureApi(apiClient)
        # Create Storage object
        api = StorageApi(apiClient)
        if envelopId != '':
            time.sleep(5)
            print envelopId
            document = signature.GetSignatureEnvelopeDocuments(
                clientId, envelopId)
            if document.status == "Ok":
                guid = document.result.documents[0].documentId
                name = document.result.documents[0].name
                currentDir = os.path.dirname(os.path.realpath(__file__))
                downloadFolder = currentDir + '/../downloads/'
                if not os.path.isdir(downloadFolder):
                    os.makedirs(downloadFolder)

                #Downlaoding of file
                fs = api.GetFile(clientId, guid)

                if fs:

                    filePath = downloadFolder + name

                    with open(filePath, 'wb') as fp:
                        shutil.copyfileobj(fs.inputStream, fp)
                                                                #Get recipient id
                                                                recipientId = getRecipient.result.recipients[
                                                                    0].id
                                                                #Convert callback string to stream
                                                                if (IsNotNull(
                                                                        callbackUrl
                                                                )):
                                                                    webHook.callbackUrl = callbackUrl
                                                                else:
                                                                    webHook.callbackUrl = ''
                                                                try:
                                                                    #Get SignatureEnvelopDocuments
                                                                    getDocuments = signature.GetSignatureEnvelopeDocuments(
                                                                        clientId,
                                                                        envelop
                                                                        .
                                                                        result.
                                                                        envelope
                                                                        .id)

                                                                    if getDocuments.status == "Ok":
                                                                        #Create signature field for sign (max LocationX,Y can bee 1.0)
                                                                        signatureSettings = SignatureEnvelopeFieldSettingsInfo
                                                                        signatureSettings.locationX = "0.15"
                                                                        signatureSettings.locationY = "0.73"
                                                                        signatureSettings.locationWidth = "150"
                                                                        signatureSettings.locationHeight = "50"
                                                                        signatureSettings.name = fieldName
                                                                        signatureSettings.forceNewField = True
                                                                        signatureSettings.page = "1"
                                                                        try: