1

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
  • @Benjamin did you ever managed to fix this? If so, I'm very interested into how... Thanks in advance! – Nsevens Aug 20 at 11:40
  • @Nsevens, do NOT waste your time trying this approach. I believe it's a Microsoft bug. I used PMP sharepoint instead and manage to get it done using that. PMP sharepoint support authentication using certificate. – Benjamin Aug 20 at 12:59
  • @Benjamin I actually managed to get it working yesterday. :) github.com/pnp/office365-cli/issues/1066 Thank you for your reply though! – Nsevens Aug 21 at 9:49

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.