Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Feature: Add support for Graph Cmdlets with Cert Thumbprint Authentication #2515

Merged
merged 2 commits into from
Mar 17, 2020
Merged

Conversation

fastlaneb
Copy link
Contributor

Type

  • Bug Fix
  • New Feature
  • Sample

Related Issues?

NullReferenceExceptions(no username present) when attempting to use Graph cmdlets after connecting with the certificate thumbprint method.

What is in this Pull Request ?

Added code in the InitiateAzureAdAppOnlyConnectionWithCert flow that creates an OAuth token and appends it to the active SPOnlineConnection object.

@fastlaneb fastlaneb changed the title Dev Feature: Add support for Graph Cmdlets with Cert Thumbprint Authentication Feb 13, 2020
@KoenZomers KoenZomers self-assigned this Feb 14, 2020
@KoenZomers
Copy link
Collaborator

@fastlaneb, can you provide exact repro steps to test this? I.e. which exact command do you use to connect and which command do you run thereafter to see that it works?

@fastlaneb
Copy link
Contributor Author

@KoenZomers Absolutely. Steps:

  1. Create an App Registration in the Azure Portal.
  2. Add an Application ID URI
  3. Upload the certificate(you may need to obtain or create one first) to the App Registration.
  4. Add the "Groups.Read.All" App permission and Grand Admin Consent.
  5. Run the following powershell:

$myCert = (Get-ChildItem -Path cert:\LocalMachine\my\ThumbprintHere)
Connect-PnPOnline -Tenant YourTenantHere.onmicrosoft.com -ClientId "ClientIDHere" -Thumbprint $myCert.Thumbprint -Url "https://YourTenantHere.sharepoint.com"
Get-PnPUnifiedGroup
Disconnect-PnPOnline

The above code will fail in the current codebase as we currently need a username/password or an appsecret to run graph commands. The fix will generate an auth token with the certificate and allow graph commands(such as the above Get-PnPUnifiedGroup).

@erwinvanhunen erwinvanhunen merged commit 2ddfaa1 into pnp:dev Mar 17, 2020
@fastlaneb fastlaneb deleted the dev branch April 13, 2020 18:20
@KoenZomers KoenZomers added status:fixed Issue fixed in current or prior release. and removed Needs: Discussion 🙋 status:to-be-reviewed labels Apr 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status:fixed Issue fixed in current or prior release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants