Edit

Share via


New-AzApiManagementUserToken

Generates a Shared Access Token for the User.

Syntax

Default (Default)

New-AzApiManagementUserToken
    -Context <PsApiManagementContext>
    -UserId <String>
    [-KeyType <PsApiManagementUserKeyType>]
    [-Expiry <DateTime>]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

Description

The cmdlet New-AzApiManagementUserToken generates a Shared Access Token for a specified User

Examples

Example 1: Generate a Shared Access Token for Git User

$context = New-AzApiManagementContext -ResourceGroupName powershelltest -ServiceName powershellsdkservice
$gitAccess=Get-AzApiManagementTenantAccess -Context $context
New-AzApiManagementUserToken -Context $context -UserId $gitAccess.Id
UserId      TokenExpiry         KeyType UserToken
------      -----------         ------- ---------
integration 5/3/2019 2:02:34 PM Primary integration&201905031402&zOwopJChWAA6oaqGHMyf7Ol9wUCPcrtdmBmff8c2lcmZk9Y...

This script get the Git user configured in ApiManagement service and generates a Shared Access Token using the Primary Key valid for 8 hours.

Example 2

Generates a Shared Access Token for the User. (autogenerated)

New-AzApiManagementUserToken -Context <PsApiManagementContext> -Expiry <DateTime> -UserId <String>

Parameters

-Context

Instance of PsApiManagementContext. This parameter is required.

Parameter properties

Type:PsApiManagementContext
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with Azure.

Parameter properties

Type:IAzureContextContainer
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzContext, AzureRmContext, AzureCredential

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Expiry

Expiry of the Token. If not specified, the token is created to expire after 8 hours. This parameter is optional.

Parameter properties

Type:

Nullable<T>[DateTime]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-KeyType

User Key to use when generating the Token. This parameter is optional.

Parameter properties

Type:PsApiManagementUserKeyType
Default value:None
Accepted values:Primary, Secondary
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-UserId

Identifier of existing user. This parameter is required.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

PsApiManagementContext

String

PsApiManagementUserKeyType

Nullable<T>

Outputs

PsApiManagementUserToken