Quantcast
Channel: Chilkat Tech Notes
Viewing all 415 articles
Browse latest View live

Convert CkDateTime to Delphi TDateTime

$
0
0

Question: Which is the best way to convert a CkDateTime to a Delphi TDateTime?

Answer: I didn’t know the answer, so I Googled “Delphi TDateTime” to see exactly what it is.  It brought me to this web page:  http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/System_TDateTime.html

In Delphi, TDateTime is a type that maps to a Double. In C++, the TDateTime class corresponds to the Delphi TDateTime type.  

The integral part of a Delphi TDateTime value is the number of days that have passed since 12/30/1899. The fractional part of the TDateTime value is fraction of a 24 hour day that has elapsed.

My experience tells me that anytime you see a date/time represented as a double, you have an OLE Date.  (Google “ole date format”)

The CkDateTime’s GetAsOleDate function returns an OLE date.  It should be just a matter of setting the Delphi TDateTime equal to the double returned by GetAsOleDate:

var
dt: HCkDateTime;
bLocal: Boolean;
// Delphi TDateTime (which is just a Double)
ddt: TDateTime;

begin
dt := CkDateTime_Create();

bLocal := True;
ddt := CkDateTime_GetAsOleDate(dt,bLocal);

CkDateTime_Dispose(dt);


Authentication Problem with Sending Email in Office365 using SMTP

$
0
0

If SMTP authentication (using login/password) fails for your smtp.office365.com account, then it may be that your account is configured to require MFA (multi-factor authentication).   You may need to change settings to allow for legacy authentication (single-factor auth).   See https://docs.microsoft.com/en-us/azure/active-directory/conditional-access/block-legacy-authentication

Also, an app password may be required.  See https://docs.microsoft.com/en-us/azure/active-directory/user-help/multi-factor-authentication-end-user-app-passwords

 

 

PHP Script for Downloading, Installing, and Testing Chilkat

$
0
0

Here is a bash shell script for downloading, unpacking, installing, and testing the 64-bit PHP 7.4 extension for Chilkat.

1) It assumes PHP 7.4 was installed to $HOME/phps/php74.
2) This example is downloading Chilkat version 9.5.0.82 (change the wget URL to the latest version)

export PATH=$HOME/phps/php74/bin:$PATH

php -v

cd
if [ ! -d testing ]; then
	mkdir testing
fi
cd testing
if [ ! -d php74 ]; then
	mkdir php74
fi
cd php74
rm -f *.tar.gz

wget http://chilkatdownload.com/9.5.0.82/chilkat-9.5.0-php-7.4-x86_64-linux.tar.gz
tar xzf chilkat*.tar.gz

cd chilkat*linux


cp chilkat_9_5_0.so $HOME/phps/php74/lib/php/extensions/no-debug-non-zts-20190902/

php test.php

ActiveX: Permission denied (Error 70)

$
0
0

A Chilkat ActiveX user (in VB6) was struggling with a “Permission denied (Error 70)”. It occurred on the very first call to a Chilkat method (UnlockBundle).

Solution:

The solution is that the ActiveX DLL somehow did not have read + execute permissions.  The 1st access to a method in the ActiveX triggered the runtime to load the DLL, and this is what caused the “Permission denied”.   The permissions on the DLL file did not allow for it to be read.

FoxPro Debugger Combined with Async Functions

$
0
0

Problem:

A Chilkat FoxPro programmer was calling Rest.FullRequestSbAsync with a 3MB request.  It failed with a WSAECONNABORTED error message.  However, calling Rest.FullRequestSb works fine.  Why?

Answer:

When the async version of a method is called, Chilkat is starting a background thread to call the synchronous version of the method.  For example, the Async method returns a Task object.  When task.Run is called, the task is scheduled to run on a background thread.  It simply calls the synchronous version of the method from the background thread.

There should be no difference.

What did the programmer neglect to divulge?  He forgot to say he was stepping through the program in the debugger.  He did the following:

I added a SUSP after loTask = loRest.FullRequestSbAsync(…) and started the debugger to get the logs.

After removing the SUSP it works fine.

 

Office365 SMTP Error: 554 5.2.0 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied;

$
0
0

Question:

I’m trying to send email using SMTP via smtp.office365.com, and I get this error:

554 5.2.0 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. 0.35250:0A001485, 1.36674:0A000000, 1.61250:00000000, 1.45378:02000000, 1.44866:59020000, 1.36674:0E000000, 1.61250:00000000, 1.45378:5E020000, 1.44866:F8000000, 16.55847:BC030000, 17.43559:0000000024020000000000000000000000000000, 20.52176:140FFA8B1500001000000000, 20.50032:140FFA8B8517001000000000, 0.35180:F1030000, 255.23226:09000000, 255.27962:0A000000, 255.27962:0E000000, 255.31418:F1030000, 0.35250:0300C981, 1.36674:0A000000, 1.61250:00000000, 1.45378:02000000, 1.44866:3A000000, 1.36674:32000000, 1.61250:00000000, 1.45378:3F000000, 1.44866:01000000, 16.55847:A6000000, 17.43559:0000000070030000000000000000000000000000, 20.52176:140FFA8B1500101040180000, 20.50032:140FFA8B8517101000000000, 0.35180:45180000, 255.23226:2D020000, 255.27962:0A000000, 255.27962:32000000, 255.17082:DC040000, 0.27745:62180000, 4.21921:DC040000, 255.27962:FA000000, 255.1494:00000000, 0.38698:00000000, 0.37692:01000000, 0.37948:FB81DB3C, 5.33852:00000000534D545000000100, 7.36354:0100000000000109302E3330, 4.56248:DC040000, 7.40748:010000000000010B3A373361, 7.57132:00000000000000006639332D, 1.63016:32000000, 4.39640:DC040000, 8.45434:0140030070B551B6000000000000000005000780, 5.10786:0000000031352E32302E333036362E3032313A444D36505232304D42323334383A37336136646161652D336435332D346639332D393535302D34396164643762356436613100E06500000000, 7.51330:7E9ED170D80CD8081A010480, 0.39570:00000000, 1.55954:0A000000, 0.49266:56000000, 1.33010:0A000000, 2.54258:00000000, 0.40002:02000000, 1.56562:00000000, 1.64146:32000000, 1.33010:32000000, 2.54258:DC040000, 255.1750:AF000000, 255.31418:0A005D36, 0.22753:A9000000, 255.21817:DC040000, 0.64418:0A00F565, 4.39842:DC040000, 0.41586:B9000000, 4.60547:DC040000, 0.21966:B3000000, 4.30158:DC040000 [Hostname=DM6PR20MB2348.namprd20.prod.outlook.com]

What is the cause?

Answer:

The Microsoft Office 365 SMTP server provided a wonderfully informative error message (sarcasm).

The clue in all of the above gibberish is the “SendAs” in “SendAsDeniedException”.  It means you authenticated using one email address, but tried to send email using another email address for the “FROM” address.  (i.e. you are “sending as” another person).

Your Office365 account may need to be setup to “Send email on behalf of another user”
See https://docs.microsoft.com/en-us/microsoft-365/admin/add-users/give-mailbox-permissions-to-another-user
This error occurs if the email address used for authentication is different than the FROM email address.
The solution is to update your Office365 account settings to allow for sending on behalf of the FROM email address.

 

Using PeerBlock can Interfere with REST API’s running on AWS Lambda

$
0
0

A Chilkat customer uses Chilkat HTTP to send REST API requests to a popular IP Geolocation service.   The REST API requests worked a few times, but then started failing with this error information in Http.LastErrorText:

ConnectFailReason: Connection rejected 
A few possible causes for a connection being rejected are: 
- A firewall (software or hardware), such as Windows Firewall, is blocking the connection . 
- Nothing is listening at the remote host:port 

The error message actually describes the cause for the failure. The customer was running PeerBlock and the IP geolocation service runs on AWS Lambda:

“This is probably happening because our service runs on AWS Lambda and is therefore served from many different IP addresses. It’s possible some of those IP addresses from Amazon had been blocked by Peerblock for malicious use by their previous owner.”

Receiving a Webhook JSON POST in Classic ASP

$
0
0

Question:

I need to setup a page in Classic ASP to serve as a webhook endpoint listener in Classic ASP
The form product we are using (Paperform) posts the data to our endpoint as a JSON post payload.

Submission payload

Webhooks POST a JSON payload on submission to the webhook URL. The JSON payload looks like the following:
{
"data": [
    {
 "title": "question 1", //Title of question as defined
 "description": "This is the second question",
 "type": "address", //Question type
 "key": "xxxxx", //Question pre-fill key (unique to form).
 "value": "343 Tester Road, Snohomish, Washington, 98290, United States" //Submitted value for question
 "custom_key": "address_1" //Custom pre-fill key (if set).
 },
 {
 "title": "question 2",
 "description": "This is the second question",
 "type": "text",
 "key": "tgp8",
 "value": "Test 123",
 "custom_key": ""
 }
//... each question has its own object.
],
"submission_id": "XXXXXXXXXXXXXXXXXXX", //Unique ID for submission.
"created_at": "2017-06-09 09:51:23", //Submission date
"ip_address": "192.168.10.1", //IP Address of submission
"charge": null //if a payment is made, payment information is given here.
}
Answer:
A typical POST that sends JSON is a POST where the request body contains the JSON document (as opposed to a multipart/form-data POST where the body contains multiple parts, or a application/x-www-form-urlencoded POST where the body is composed of keys and values encoded in key-value tuples separated by ‘&’, with a ‘=’ between the key and the value.
Therefore, you want to get the raw body of the POST, and you do it like this:
If Request.TotalBytes > 0 Then
    Dim lngBytesCount
        lngBytesCount = Request.TotalBytes
    jsonStr = BytesToStr(Request.BinaryRead(lngBytesCount))
End If
However, JSON uses the utf-8 byte representation.  I would guess that BytesToStr is expecting the bytes to be in ANSI representation and would mangle non-us-ascii chars.  It would be safer to use Chilkat to be explicit about utf-8 encoding:
set bd = Server.CreateObject("Chilkat_9_5_0.BinData")
success = bd.AppendBinary(Request.BinaryRead(lngBytesCount))
set sbJson = Server.CreateObject("Chilkat_9_5_0.StringBuilder")
success = sbJson.AppendBd(bd,"utf-8",0,0)

' now you have the JSON in a Chilkat StringBuilder object.
' you can access it as a string in ASP
strJson = sbJson.GetAsString()

' or you can load it directly into a JsonObject
set json = Server.CreateObject("Chilkat_9_5_0.JsonObject")
success = json.LoadSb(sbJson)

Chilkat v9.5.0.83 Release Notes

$
0
0

The previous version release notes: Chilkat v9.5.0.82 Release Notes

Chilkat v9.5.0.83 Release Notes

  • 25-Mar-2020 SHA3: Added the SHA3 hash algorithms: sha3-224, sha3-256, sha3-384, sha3-512. The SHA3 hash algorithms may generally be used in any property or method of any Chilkat class where a hash algorithm is specified.
  • 25-Mar-2020 MailMan: Added OAuth2 authentication capability (“AUTH XOAUTH2”) for POP3 servers such as pop.gmail.com that support the XOAUTH2 authentication mechanism.
  • 26-Mar-2020 Csv: Added the SortByColumnIndex method.
  • 31-Mar-2020 AuthAzureStorage: Fixed authentication problems for the Table service.
  • 2-April-2020 chilkat2-python:  The LastMethodSuccess property is not getting set correctly.  Also, methods that return objects are returning NULL when failing, but should return None.
  • 5-April-2020 SshKey: Added the KeyType property.
  • 5-April-2020 SshKey: Added the GenerateEd25519Key and GenerateEcdsaKey methods.
  • 8-April-2020 PrivateKey: Added the LoadEd25519 method to load an ed25519 private key from two 32-byte hex strings.
  • 8-April-2020: PublicKey: Added the LoadEd25519 method to load an ed25519 public key from a 32-byte hex string.
  • 15-April-2020: Stream: Added the SinkFileAppend property (boolean) to control whether the SinkFile is opened for append or truncate/rewrite.  The default value is false for truncate/rewrite.
  • 28-April-2020: Smartcard: Improved internal functionality relating to SmartCards, Storage Providers, etc.  This is for Cert.LoadFromSmartcard, CertStore.OpenSmartcard, etc.
  • 28-April-2020: ECDSA Certificates: Improved support for ECDSA certs.
  • 28-April-2020: Ed25519: Improved support for Ed25519 private keys.
  • 28-April-2020: EdDSA: Added an EdDSA class for Ed25519 signatures and key generation.
  • 28-April-2020: Upload: Added the ResponseBodyStr property.
  • 4-May-2020: Cert: Added the LoadByThumbprint method.  (Windows-only method to search Windows certificate stores for the certificate having a given SHA1 or MD5 hash/thumbprint.)
  • 5-May-2020: Http: The QuickPutStr method will now automatically include the “Content-Length: 0” header.
  • 11-May-2020: Pfx: Added the following properties and method: AlgorithmId, Pbes2CryptAlg, Pbes2HmacAlg, LastJsonData, UncommonOptions
  • 11-May-2020: Rest: Fixed crash bug in Rest.ReadResponseHeader (a rare situation)
  • 14-May-2020: Crypt2: Added two new methods: AddSigningCert, ClearSigningCerts.  This is to make it possible to create CMS signatures with multiple signers.
  • 16-May-2020: Spider: Fixed a bug where not all Unspidered URLs were collected.
  • 17-May-2020: Cert: Deprecated/removed the LinkPrivateKey method.  The LinkPrivateKey method should not be needed.  If your application uses it, contact Chilkat for help about how to modify your code.  It’s likely you can simply remove the call altogether.
  • 30-May-2020: Http: Added the ProxyDirectTls property to support Direct TLS Connection to an HTTP Proxy (such as for a squid cache proxy server).
  • 5-June-2020: Cert: Fixed the “Cert's public key does not match the private key.” error that could sometimes occur in the cert.LoadPfxFile method.
  • 18-June-2020: SFtp: (Fixed) The ReadFileBytes64 method, if reading past the end of the file, did not cause the Eof(handle) function to subsequently return True.
  • 19-June-2020: LastStringResult: For the ActiveX builds, the following properties needed to be added to BinData and StringBuilder: LastStringResult, LastStringResultLen, LastBinaryResult.

Apple Mail warning: Unable to Verify Message Signature

$
0
0

If Apple Mail displays the warning “Unable to verify message signature”, and when clicking details it says:

The digital signature is incorrect. The message may have been tampered with or corrupted since signed by (sender’s name).

the reason is due to a bug in Apple Mail (possibly introduced in a recent version of MacOSX).

See https://apple.stackexchange.com/questions/343251/apple-mail-warning-unable-to-verify-message-signature

“When Mail is set to not automatically load remote content (Preferences > Viewing > Load remote content in messages is not checked), then the warning message Unable to verify message signature is displayed for every S/MIME signed message.

You can get rid of the warning by either

  • Setting Mail to automatically load remote content (set Preferences > Viewing > Load remote content in messages to checked) not recommended
  • Clicking on the “Load Remote Content” button displayed on the right of the warning message

However, for security reasons, it is not recommended to load remote content unless it is from a trusted source.”

 

 

Chilkat v9.5.0.84 Pre-Release Notes

$
0
0
The previous version release notes: Chilkat v9.5.0.83 Release Notes

Chilkat v9.5.0.84 Pre-Release Notes

  • 17-Jul-2020 CSR: Added the AddSan method to allow for 1 or more Subject Alternative Names to be added to the CSR that is generated.

GMail IMAP OAuth2 – A Walkthrough

$
0
0

This blog post covers from start to finish the process for getting a desktop application working with GMail using the IMAP protocol with OAuth2 authentication.

Start here:  https://console.developers.google.com/apis/credentials

(1) The first step is to create credentials.  Your app is a desktop application.  HOWEVER, you will be creating credentials as if your app is a web app.

See this YouTube video demonstrating how to create the Client ID and Client Secret:   https://youtu.be/EZK2ZGmfX2k

(2) The 2nd step is to get the initial OAuth2 token from a desktop application.   See these examples:

C: Get GMail IMAP OAuth2 Access Token for Desktop App
Chilkat2-Python: Get GMail IMAP OAuth2 Access Token for Desktop App
C++: Get GMail IMAP OAuth2 Access Token for Desktop App
C#: Get GMail IMAP OAuth2 Access Token for Desktop App
DataFlex: Get GMail IMAP OAuth2 Access Token for Desktop App
Delphi ActiveX: Get GMail IMAP OAuth2 Access Token for Desktop App
Delphi DLL: Get GMail IMAP OAuth2 Access Token for Desktop App
Visual FoxPro: Get GMail IMAP OAuth2 Access Token for Desktop App
Go: Get GMail IMAP OAuth2 Access Token for Desktop App
Java: Get GMail IMAP OAuth2 Access Token for Desktop App
Node.js: Get GMail IMAP OAuth2 Access Token for Desktop App
Objective-C: Get GMail IMAP OAuth2 Access Token for Desktop App
Perl: Get GMail IMAP OAuth2 Access Token for Desktop App
PHP ActiveX: Get GMail IMAP OAuth2 Access Token for Desktop App
PHP Extension: Get GMail IMAP OAuth2 Access Token for Desktop App
PowerBuilder: Get GMail IMAP OAuth2 Access Token for Desktop App
PowerShell: Get GMail IMAP OAuth2 Access Token for Desktop App
PureBasic: Get GMail IMAP OAuth2 Access Token for Desktop App
CkPython: Get GMail IMAP OAuth2 Access Token for Desktop App
Ruby: Get GMail IMAP OAuth2 Access Token for Desktop App
Swift 2: Get GMail IMAP OAuth2 Access Token for Desktop App
Swift 3,4,5…: Get GMail IMAP OAuth2 Access Token for Desktop App
Tcl: Get GMail IMAP OAuth2 Access Token for Desktop App
Unicode C: Get GMail IMAP OAuth2 Access Token for Desktop App
Unicode C++: Get GMail IMAP OAuth2 Access Token for Desktop App
Visual Basic 6.0: Get GMail IMAP OAuth2 Access Token for Desktop App
VB.NET: Get GMail IMAP OAuth2 Access Token for Desktop App
VBScript: Get GMail IMAP OAuth2 Access Token for Desktop App
Xojo Plugin: Get GMail IMAP OAuth2 Access Token for Desktop App

The code to get the initial OAuth2 access token will popup a browser to allow the GMail account owner to authorize the access.

This YouTube video shows it: https://www.youtube.com/watch?v=MBwUOs_JqOM

(3) The last step is to use the access token in your application to authenticate with the GMail IMAP server.   See these examples:

C: GMail IMAP Authentication using OAuth2 Access Token
Chilkat2-Python: GMail IMAP Authentication using OAuth2 Access Token
C++: GMail IMAP Authentication using OAuth2 Access Token
C#: GMail IMAP Authentication using OAuth2 Access Token
DataFlex: GMail IMAP Authentication using OAuth2 Access Token
Delphi ActiveX: GMail IMAP Authentication using OAuth2 Access Token
Delphi DLL: GMail IMAP Authentication using OAuth2 Access Token
Visual FoxPro: GMail IMAP Authentication using OAuth2 Access Token
Go: GMail IMAP Authentication using OAuth2 Access Token
Java: GMail IMAP Authentication using OAuth2 Access Token
Node.js: GMail IMAP Authentication using OAuth2 Access Token
Objective-C: GMail IMAP Authentication using OAuth2 Access Token
Perl: GMail IMAP Authentication using OAuth2 Access Token
PHP ActiveX: GMail IMAP Authentication using OAuth2 Access Token
PHP Extension: GMail IMAP Authentication using OAuth2 Access Token
PowerBuilder: GMail IMAP Authentication using OAuth2 Access Token
PowerShell: GMail IMAP Authentication using OAuth2 Access Token
PureBasic: GMail IMAP Authentication using OAuth2 Access Token
CkPython: GMail IMAP Authentication using OAuth2 Access Token
Ruby: GMail IMAP Authentication using OAuth2 Access Token
SQL Server: GMail IMAP Authentication using OAuth2 Access Token
Swift 2: GMail IMAP Authentication using OAuth2 Access Token
Swift 3,4,5…: GMail IMAP Authentication using OAuth2 Access Token
Tcl: GMail IMAP Authentication using OAuth2 Access Token
Unicode C: GMail IMAP Authentication using OAuth2 Access Token
Unicode C++: GMail IMAP Authentication using OAuth2 Access Token
Visual Basic 6.0: GMail IMAP Authentication using OAuth2 Access Token
VB.NET: GMail IMAP Authentication using OAuth2 Access Token
VBScript: GMail IMAP Authentication using OAuth2 Access Token
Xojo Plugin: GMail IMAP Authentication using OAuth2 Access Token

(4) After an hour, your access token will expire and will need to be refreshed.  This example showsn how to refresh the access token:

C: Refresh GMail IMAP OAuth2 Access Token
Chilkat2-Python: Refresh GMail IMAP OAuth2 Access Token
C++: Refresh GMail IMAP OAuth2 Access Token
C#: Refresh GMail IMAP OAuth2 Access Token
DataFlex: Refresh GMail IMAP OAuth2 Access Token
Delphi ActiveX: Refresh GMail IMAP OAuth2 Access Token
Delphi DLL: Refresh GMail IMAP OAuth2 Access Token
Visual FoxPro: Refresh GMail IMAP OAuth2 Access Token
Go: Refresh GMail IMAP OAuth2 Access Token
Java: Refresh GMail IMAP OAuth2 Access Token
Node.js: Refresh GMail IMAP OAuth2 Access Token
Objective-C: Refresh GMail IMAP OAuth2 Access Token
Perl: Refresh GMail IMAP OAuth2 Access Token
PHP ActiveX: Refresh GMail IMAP OAuth2 Access Token
PHP Extension: Refresh GMail IMAP OAuth2 Access Token
PowerBuilder: Refresh GMail IMAP OAuth2 Access Token
PowerShell: Refresh GMail IMAP OAuth2 Access Token
PureBasic: Refresh GMail IMAP OAuth2 Access Token
CkPython: Refresh GMail IMAP OAuth2 Access Token
Ruby: Refresh GMail IMAP OAuth2 Access Token
Swift 2: Refresh GMail IMAP OAuth2 Access Token
Swift 3,4,5…: Refresh GMail IMAP OAuth2 Access Token
Tcl: Refresh GMail IMAP OAuth2 Access Token
Unicode C: Refresh GMail IMAP OAuth2 Access Token
Unicode C++: Refresh GMail IMAP OAuth2 Access Token
Visual Basic 6.0: Refresh GMail IMAP OAuth2 Access Token
VB.NET: Refresh GMail IMAP OAuth2 Access Token
VBScript: Refresh GMail IMAP OAuth2 Access Token
Xojo Plugin: Refresh GMail IMAP OAuth2 Access Token

 

 

Chilkat v9.5.0.85 Pre-Release Notes

Add-Type PowerShell Error for ChilkatDotNet47.dll

$
0
0

Problem:   The following command:

Add-Type -Path "C:\chilkat\ChilkatDotNet47-9.5.0-x64\ChilkatDotNet47.dll"

results in the following errors when attempting to run in PowerShell:

+ Add-Type -Path"C:\chilkat\chilkatdotnet47-9.5.0-x64\ChilkatDotNet47.d ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidData : (Microsoft.Power...peCompilerError:AddTypeCompilerError) [Add-Type], Exception
+ FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand
Add-Type : Impossible d'ajouter un type. Des erreurs de compilation se sont produites.
Au caractère C:\ProgramData\C1B2.ps1:1 : 1
+ Add-Type -Path"C:\chilkat\chilkatdotnet47-9.5.0-x64\ChilkatDotNet47.d ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidData : (:) [Add-Type], InvalidOperationException
+ FullyQualifiedErrorId : COMPILER_ERRORS,Microsoft.PowerShell.Commands.AddTypeCommand 
New-Object : Le type [Chilkat.Global] est introuvable : vérifiez que l'assembly dans lequel il se trouve est chargé.
Au caractère C:\ProgramData\C1B2.ps1:2 : 7
+ $glob=New-Object Chilkat.Global
+       ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
Impossible d'appeler une méthode dans une expression Null.
Au caractère C:\ProgramData\C1B2.ps1:3 : 1
+ $success=$glob.UnlockBundle("...")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidOperation : (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull

Solution:

Il faut aller dans les propriétés de votre DLL et cocher « Débloquer » et là cela fonctionne parfaitement

(You have to go to the properties of your DLL and check “Unblock” and there it works perfectly)

Native App packaged via Packaging Project and distributed via Windows App Store.

$
0
0

Question:

Do you have a way to ship both the x64 and x86 dlls and have the
application decide which gets loaded? (I believe this is what SQLite
does). I’ve got a native app that is packaged via a ‘Packaging
Project’ and is then distributed via the Windows App store. Because of
this distribution method, I cannot ship two separate installers and I
can also not install anything to the GAC. This limits me to shipping
just 32 bit.

Answer:

I manually edited my .csproject and added the following:

<ItemGroup Condition=" '$(Platform)' == 'x86' ">
<Reference Include="ChilkatDotNet46, Version=9.5.0.84, Culture=neutral, PublicKeyToken=eb5fc1fc52ef09be, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\libs\Chilkat\x86\ChilkatDotNet46.dll</HintPath>
</Reference>
</ItemGroup>

<ItemGroup Condition=" '$(Platform)' == 'x64' ">
<Reference Include="ChilkatDotNet46, Version=9.5.0.84, Culture=neutral, PublicKeyToken=eb5fc1fc52ef09be, processorArchitecture=x64">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\libs\Chilkat\x64\ChilkatDotNet46.dll</HintPath>
</Reference>
</ItemGroup>

So far this seems to be working fine – as long as I don’t use ‘Any CPU’ (which would probably work if I did the prefer x84, but I don’t want to confuse things further).

The packaging project for the app store generates a subfolder for x86 and x64 which each contains duplicate content for both x86/x64 except for the Chilkat.dll. It seems that this will do the trick!

Thanks again for the great libraries.

 


Xero Redirect URI for OAuth2 and Desktop Apps

$
0
0

This post is about Xero OAuth2 for desktop apps, but the same concepts generally apply to all other applications (REST API apps) using OAuth2.

What many developers don’t initially realize (if new to OAuth2) is that an “App” needs to be defined in the developer portal for the service (i.e. Xero in this case).   For Xero, you would login to developer.xero.com and define an App at https://developer.xero.com/myapps/    This is where you get a Client_ID and Client_Secret.   It is also where you specify one or more valid redirect URIs.   For desktop apps, your redirect URI will be a “localhost” URL that begins with “http://” (not “https://” ) and uses a port number that no other process on the computer is likely to use. For example, you might specify a redirect URI of “http://localhost:55568/”.   (Note that the trailing “/” is important to include.)

In your application code using Chilkat, such as here:   https://www.example-code.com/csharp/xero_oauth2.asp you would specify the same port number for your oauth2.ListenPort.

If the port numbers don’t match, or if the Redirect URI is not specified exactly as described above,  you’ll get the following error when trying to get an OAuth2 access token:

Error code: 500
Error: unauthorized_client : Invalid redirect_uri

For example, here is a screenshot of a Xero app with the Redirect URI correctly defined.

Xero MyApps

Chilkat v9.5.0.86 Release Notes

$
0
0

The previous version release notes: Chilkat v9.5.0.85 Release Notes

Chilkat v9.5.0.86 Release Notes

  • 10-Feb-2021 Pdf: Immediately after releasing v9.5.0.85, it was discovered that many PDF’s had the following error when viewed in Acrobat DC after signing:  “”The signature byte range is invalid””.  It was deemed important enough to fix and release v9.5.0.86.  Therefore, this version is the same as v9.5.0.85 with this additional fix.

Chilkat v9.5.0.87 Pre-Release Notes

$
0
0

The previous version release notes: Chilkat v9.5.0.86 Release Notes

Chilkat v9.5.0.87 Pre-Release Notes

  • 1-Mar-2021 Http: When automatically following redirects, Chilkat was mistakenly removing the Authorization header for all redirects. The fix is to only remove the Authorization header when the redirect is to another domain.

GMail IMAP NO [AUTHENTICATIONFAILED] Invalid credentials (Failure)

$
0
0

You passed the correct login/password to login to imap.gmail.com, but you still get an “Invalid credentials” error.  What gives?

For example, you called Chilkat’s Imap.Login method, passing the correct login/password, and the imap.LastErrorText contains this:

authenticateLogin(110ms):
        loginImap(110ms):
          ConnectionType: SSL/TLS
          ImapCmdSent: aaab LOGIN "you@gmail.com"
          getCompleteResponse(110ms):
            ImapCmdResp: aaab NO [AUTHENTICATIONFAILED] Invalid credentials (Failure)
          --getCompleteResponse
        --loginImap
        isOK:
          serverResponse: aaab NO [AUTHENTICATIONFAILED] Invalid credentials (Failure)
        --isOK
--authenticateLogin

The answer is that your GMail account needs to be enabled for “Less Secure Apps”.

Note: Chilkat also supports OAuth2 IMAP authentication (i.e. secure apps) with GMail, and this requires an OAuth2 access token to be obtained first.  There are examples for this on example-code.com

To enable “Less Secure Apps” in your Google account, go to your Google Account Security Settings at https://myaccount.google.com/security

Scroll down and look for the “Less Secure Apps” section:

google_account_security_1

Click on “Turn on access” and then turn on access.  See below:

google_account_security_2

Re-run your program.  Now it succeeds and your LastErrorText shows this:

      authenticateLogin(250ms):
        loginImap(250ms):
          ConnectionType: SSL/TLS
          ImapCmdSent: aaab LOGIN "you@gmail.com"
          getCompleteResponse(250ms):
            ImapCmdResp: * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE ENABLE MOVE CONDSTORE ESEARCH UTF8=ACCEPT LIST-EXTENDED LIST-STATUS LITERAL- SPECIAL-USE APPENDLIMIT=35651584
            ImapCmdResp: aaab OK you@gmail.com authenticated (Success)
          --getCompleteResponse
        --loginImap
        isOK:
          serverResponse: aaab OK you@gmail.com authenticated (Success)
        --isOK
      --authenticateLogin

 

Async Node.js Example to Read Many Imap Accounts in Parallel

$
0
0
This example demonstrates how to use Chilkat to connect to many IMAP accounts in parallel to do something..

var os = require('os');
if (os.platform() == 'win32') {
    if (os.arch() == 'ia32') {
        var chilkat = require('@chilkat/ck-node14-win-ia32');
    } else {
        var chilkat = require('@chilkat/ck-node14-win64');
    }
} else if (os.platform() == 'linux') {
    if (os.arch() == 'arm') {
        var chilkat = require('@chilkat/ck-node14-arm');
    } else if (os.arch() == 'x86') {
        var chilkat = require('@chilkat/ck-node14-linux32');
    } else {
        var chilkat = require('@chilkat/ck-node14-linux64');
    }
} else if (os.platform() == 'darwin') {
    var chilkat = require('@chilkat/ck-node14-macosx');
}

function unlockChilkat() {

    var glob = new chilkat.Global();
    var success = glob.UnlockBundle("Anything for 30-day trial");
    if (success !== true) {
        console.log(glob.LastErrorText);
        return;
    }

}


function chilkatAsyncExample(json) {

    const account = JSON.parse(json);

    var imap = new chilkat.Imap();

    imap.Ssl = true;
    imap.Port = 993;
    var taskConnect = imap.ConnectAsync(account.server);
    taskConnect.UserData = json;

    const disconnectCompleted = (task) => {
        const account = JSON.parse(task.UserData);
        if (task.StatusInt != 7) {
            console.log("Disconnect did not complete.");
            console.log("task status: " + task.Status);
            console.log("account: " + account.email);
            reject('IMAP disconnect error');
        }

        console.log("Success: " + account.email);
    }


    const mailboxSelectCompleted = (task) => {
        const account = JSON.parse(task.UserData);
        if (task.StatusInt != 7) {
            console.log("Mailbox select did not complete.");
            console.log("task status: " + task.Status);
            console.log("account: " + account.email);
            reject('mailbox select error');
        }

        console.log("Folder selected: " + account.email);

        // Disconnect from the IMAP server.
        var taskDisconnect = imap.DisconnectAsync();
        taskDisconnect.UserData = task.UserData;

        success = taskDisconnect.Run(disconnectCompleted);
        if (success != true) {
            console.log(taskDisconnect.LastErrorText);
        }

    }

    const loginCompleted = (task) => {
        const account = JSON.parse(task.UserData);

        if (task.StatusInt != 7) {
            console.log("Login did not complete.");
            console.log("task status: " + task.Status);
            console.log("account: " + account.email);
            reject('login error');
        }

        console.log("Login successful: " + account.email);

        // Select an IMAP folder/mailbox
        var taskSelectMaibox = imap.SelectMailboxAsync("Inbox");
        taskSelectMaibox.UserData = task.UserData;

        success = taskSelectMaibox.Run(mailboxSelectCompleted);
        if (success != true) {
            console.log(taskSelectMaibox.LastErrorText);
        }

    }

    const connectCompleted = (task) => {
        const account = JSON.parse(task.UserData);
        if (task.StatusInt != 7) {
            console.log("Connect did not complete.");
            console.log("task status: " + task.Status);
            console.log("account: " + account.email);
            reject('connection error');
        }

        console.log("Connected: " + account.email);

        var taskLogin = imap.LoginAsync(account.email, account.password);
        taskLogin.UserData = task.UserData;

        success = taskLogin.Run(loginCompleted);
        if (success != true) {
            console.log(taskLogin.LastErrorText);
        }

    }

    success = taskConnect.Run(connectCompleted);
    if (success != true) {
        console.log(taskConnect.LastErrorText);
    }


}



unlockChilkat();

chilkatAsyncExample('{"server":"imap-mail.outlook.com","email":"chilkat@live.com","password":"***"}');
chilkatAsyncExample('{"server":"imap.mail.us-west-2.awsapps.com","email":"qa@chilkatsoft.com","password":"***"}');
// ....

Viewing all 415 articles
Browse latest View live