Skip to content

Get the access token for Microsoft Graph #16006

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Accounts/Accounts/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
-->

## Upcoming Release
* Supported getting the access token for Microsoft Graph.
* Added AuthorizeRequestDelegate to allow service module to adjust token audience.
* Utilized [AssemblyLoadContext](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.loader.assemblyloadcontext) to resolve assembly conflict issues in PowerShell.
* Updated Azure.Core from 1.16.0 to 1.19.0.
Expand Down
3 changes: 2 additions & 1 deletion src/Accounts/Accounts/Token/GetAzureRmAccessToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ public class GetAzureRmAccessTokenCommand : AzureRMCmdlet

[Parameter(ParameterSetName = KnownResourceNameParameterSet,
Mandatory = false,
HelpMessage = "Optional resouce type name, supported values: AadGraph, AnalysisServices, Arm, Attestation, Batch, DataLake, KeyVault, OperationalInsights, ResourceManager, Storage, Synapse. Default value is Arm if not specified.")]
HelpMessage = "Optional resource type name, supported values: AadGraph, AnalysisServices, Arm, Attestation, Batch, DataLake, KeyVault, MSGraph, OperationalInsights, ResourceManager, Storage, Synapse. Default value is Arm if not specified.")]
[PSArgumentCompleter(
SupportedResourceNames.AadGraph,
SupportedResourceNames.MSGraph,
SupportedResourceNames.AnalysisServices,
SupportedResourceNames.Arm,
SupportedResourceNames.Attestation,
Expand Down
2 changes: 2 additions & 0 deletions src/Accounts/Accounts/Utilities/SupportedResourceNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ internal class SupportedResourceNames
{
public const string Arm = "Arm";
public const string AadGraph = "AadGraph";
public const string MSGraph = "MSGraph";
public const string Batch = "Batch";
public const string DataLake = "DataLake";
public const string KeyVault = "KeyVault";
Expand All @@ -43,6 +44,7 @@ static SupportedResourceNames()
DataPlaneResourceNameMap = new Dictionary<string, string>()
{
{ AadGraph, AzureEnvironment.Endpoint.GraphEndpointResourceId },
{ MSGraph, AzureEnvironment.ExtendedEndpoint.MicrosoftGraphEndpointResourceId },
{ Batch, AzureEnvironment.Endpoint.BatchEndpointResourceId },
{ DataLake, AzureEnvironment.Endpoint.DataLakeEndpointResourceId },
{ KeyVault, AzureEnvironment.Endpoint.AzureKeyVaultServiceEndpointResourceId },
Expand Down
20 changes: 10 additions & 10 deletions src/Accounts/Accounts/help/Get-AzAccessToken.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,26 @@ Get access token

## EXAMPLES

### Example 1 Get raw access token for ARM endpoint
### Example 1 Get the access token for ARM endpoint
```powershell
PS C:\> Get-AzAccessToken
```

Get access token of ResourceManager endpoint for current account
Get access token of current account for ResourceManager endpoint

### Example 2 Get raw access token for AAD graph endpoint
### Example 2 Get the access token for Microsoft Graph endpoint
```powershell
PS C:\> Get-AzAccessToken -ResourceTypeName AadGraph
PS C:\> Get-AzAccessToken -ResourceTypeName MSGraph
```

Get access token of AAD graph endpoint for current account
Get access token of Microsoft Graph endpoint for current account

### Example 3 Get raw access token for AAD graph endpoint
### Example 3 Get the access token for Microsoft Graph endpoint
```powershell
PS C:\> Get-AzAccessToken -ResourceUrl "https://graph.windows.net/"
PS C:\> Get-AzAccessToken -ResourceUrl "https://graph.microsoft.com/"
```

Get access token of AAD graph endpoint for current account
Get access token of Microsoft Graph endpoint for current account

## PARAMETERS

Expand All @@ -68,7 +68,7 @@ Accept wildcard characters: False
```

### -ResourceTypeName
Optional resouce type name, supported values: AadGraph, AnalysisServices, Arm, Attestation, Batch, DataLake, KeyVault, OperationalInsights, ResourceManager, Storage, Synapse. Default value is Arm if not specified.
Optional resource type name, supported values: AadGraph, AnalysisServices, Arm, Attestation, Batch, DataLake, KeyVault, MSGraph, OperationalInsights, ResourceManager, Storage, Synapse. Default value is Arm if not specified.

```yaml
Type: System.String
Expand All @@ -83,7 +83,7 @@ Accept wildcard characters: False
```

### -ResourceUrl
Resource url for that you're requesting token, e.g. 'http://graph.windows.net/'.
Resource url for that you're requesting token, e.g. 'https://graph.microsoft.com/'.

```yaml
Type: System.String
Expand Down
34 changes: 17 additions & 17 deletions tools/Common.Netcore.Dependencies.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
<ItemGroup>
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.23"/>
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure" Version="3.3.19"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Aks" Version="1.3.45-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Authentication.Abstractions" Version="1.3.45-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Authorization" Version="1.3.45-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Common" Version="1.3.45-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Compute" Version="1.3.45-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Graph.Rbac" Version="1.3.45-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.KeyVault" Version="1.3.45-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Monitor" Version="1.3.45-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Network" Version="1.3.45-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.PolicyInsights" Version="1.3.45-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.ResourceManager" Version="1.3.45-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Storage" Version="1.3.45-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Storage.Management" Version="1.3.45-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Strategies" Version="1.3.45-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Websites" Version="1.3.45-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Common.Share" Version="1.3.45-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Aks" Version="1.3.47-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Authentication.Abstractions" Version="1.3.47-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Authorization" Version="1.3.47-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Common" Version="1.3.47-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Compute" Version="1.3.47-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Graph.Rbac" Version="1.3.47-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.KeyVault" Version="1.3.47-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Monitor" Version="1.3.47-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Network" Version="1.3.47-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.PolicyInsights" Version="1.3.47-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.ResourceManager" Version="1.3.47-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Storage" Version="1.3.47-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Storage.Management" Version="1.3.47-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Strategies" Version="1.3.47-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Clients.Websites" Version="1.3.47-preview"/>
<PackageReference Include="Microsoft.Azure.PowerShell.Common.Share" Version="1.3.47-preview"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Azure.Core" Version="1.19.0"/>
Expand All @@ -36,7 +36,7 @@
<PackageReference Include="PowerShellStandard.Library" Version="5.1.0" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup>
<StorageToolsPath>$(NugetPackageRoot)\microsoft.azure.powershell.storage\1.3.45-preview\tools\</StorageToolsPath>
<StorageToolsPath>$(NugetPackageRoot)\microsoft.azure.powershell.storage\1.3.47-preview\tools\</StorageToolsPath>
</PropertyGroup>
<ItemGroup Condition="'$(OmitJsonPackage)' != 'true'">
<PackageReference Include="Newtonsoft.Json" Version="10.0.3"/>
Expand Down