I am trying to authenticate into a SharePoint Online using the command prompt and Certificate instead of Username and Password.
I have read their official documentation here.
The command to login using certificate is :
spo login https://contoso-admin.sharepoint.com --authType certificate --certificateFile /Users/user/dev/localhost.pfx --thumbprint 47C4885736C624E90491F32B98855AA8A7562AF1
I have followed all the necessary steps such as :
Creating Azure AD App,
Generate and Upload the Certificate to Azure AD,
and setting the 2 environment variables which are
OFFICE365CLI_TENANTon my computer .
and when I try to login I am getting the following error :
SelfSignedJwt: ERROR: Failed to sign JWT. This is most likely due to an invalid certificate.
I have no clue where is root cause of issue, but I am guessing it's due to the way I generate the certificate. The documentation has not provided any information about how to generate the certificate.
I have generated my certificate using the following command in PowerShell:
New-SelfSignedCertificate -Subject "CN=CertSample" -CertStoreLocation "Cert:\CurrentUser\My" -KeyExportPolicy Exportable -KeySpec Signature -NotAfter (Get-Date).AddYears(2)