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 :

  1. Creating Azure AD App,

  2. Generate and Upload the Certificate to Azure AD,

  3. and setting the 2 environment variables which are OFFICE365CLI_AADAADAPPID and OFFICE365CLI_TENANT on 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)
  • you will have to create it as mentioned here – Gautam Sheth May 8 at 6:36
  • same error at the end. – Benjamin May 9 at 6:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.