PowerCLI Reference

New-VcsOAuthSecurityContext

Synopsis

Creates an OAuth2 security context object that you can use to authenticate a user with any VMware Cloud Service.

Syntax

New-VcsOAuthSecurityContext [[-VcsServer] <String>] -ApiToken <SecureString> [-IgnoreSslValidationErrors] [<CommonParameters>]

New-VcsOAuthSecurityContext [[-VcsServer] <String>] -AppId <String> -AppSecret <SecureString> [-IgnoreSslValidationErrors] -OrganizationId <String> -RedirectUrl <Uri> [<CommonParameters>]

New-VcsOAuthSecurityContext [[-VcsServer] <String>] -AppId <String> -AppSecret <SecureString> [-IgnoreSslValidationErrors] -OrganizationId <String> [<CommonParameters>]

Related Commands

Online Version

Detailed Description

Creates an OAuth2 security context object that you can use to authenticate a user with any VMware Cloud Service.


For more information about security contexts, see the about_security_context article.


This command supports the following authentication options: - authenticate as a user who operates with the specified API token from the VMware Cloud Services web portal.


- authenticate as a user by going to the VMware Cloud Services web portal and providing the credentials of the Web App registered with the VMware Cloud Services web portal. For this operation, you need to create a Web App in the VMware Cloud Services web portal with a redirect URL that is on a localhost and uses the http schema and a port that is free on the machine where PowerCLI is running. When you create the Web App in the web portal, take note of the App ID and secret.


- authenticate as a service application by using the credentials of a Service-To-Service App. For this operation, you need to create a Service-to-Service App in the the VMware Cloud Services server. When you create the Service-to-Service application, add the application to the organization where you want it to operate. Take note of the App ID and secret.

Parameters

NameTypeDescriptionRequired?Pipeline InputDefault Value
VcsServerStringSpecifies the host name of the VMware Cloud Services API endpoint for the particular instance. The default value is `console.cloud.vmware.com`. You can find the value for your particular instance in the Developer Center section of the VMware Cloud Services web portal.falseFalse
ApiTokenSecureStringSpecifies the API token you want to use for authentication with the VMware Cloud Services server. The token is obtained from the VMware Cloud Services web portal.trueFalse
AppIdStringSpecifies the ID of an OAuth App registered in the VMware Cloud Services web portal.trueFalse
AppSecretSecureStringSpecifies the secret of an OAuth App registered in the VMware Cloud Services web portal. You can retrieve the secret from the portal only when you create the application.trueFalse
IgnoreSslValidationErrorsSwitchParameterIf specified, any errors with the SSL certificate of the server are ignored.falseFalse
OrganizationIdStringSpecifies the ID of the organization where the access tokens from the security context are valid for. You can see the organization ID in the VMware Cloud Services web portal.trueFalse
RedirectUrlUriSpecifies the Redirect URL of the Web App that you created in the VMware Cloud Services web portal for PowerCLI. This URL must be on localhost and a free port on the machine where PowerCLI is running. This URL must use the http schema.trueFalse

Return Type

VMware.VimAutomation.Vmc.Types.V1.VcsOAuthSecurityContext

Notes

Examples

-------------------------- Example 1 --------------------------

$oauthCtx = New-VcsOAuthSecurityContext -ApiToken "a3f35067-80b5-44f0-a0bc-e19f2bc17fb7"

Creates an OAuth2 security context object by authenticating the user with an API token from the VMware Cloud Services web portal.

-------------------------- Example 2 --------------------------

$oauthCtx = New-VcsOAuthSecurityContext -VcsServer "console.cloud.vmware.com" -ApiToken "a3f35067-80b5-44f0-a0bc-e19f2bc17fb7"

Creates an OAuth2 security context object by authenticating the user with an API token from the VMware Cloud Services web portal for a particular instance of the service. In this example, that is the public commercial instance at https://console.cloud.vmware.com.

-------------------------- Example 3 --------------------------

$oauthCtx = New-VcsOAuthSecurityContext New-VcsOAuthSecurityContext `
      -AppId "VOu3Vhx...d5jYPfS" `
      -AppSecret "zfqytuK...G6mIGL8" `
      -OrganizationId '22b98eec-cdc2-42b8-b770-835e72ecc7c3'

Creates an OAuth2 security context object by authenticating as a service application using the credentials of a Service-To-Service App registered with the VMware Cloud Services web portal.

-------------------------- Example 4 --------------------------

$oauthCtx = New-VcsOAuthSecurityContext New-VcsOAuthSecurityContext `
      -AppId "VOu3Vhx...d5jYPfS" `
      -AppSecret "zfqytuK...G6mIGL8" `
      -OrganizationId '22b98eec-cdc2-42b8-b770-835e72ecc7c3' `
      -RedirectUrl 'http://localhost:8877/powercli'

Creates an OAuth2 security context object by authenticating through the VMware Cloud Services web portal and providing the credentials of a Web App.


For this operation, you need to create a Web App in the VMware Cloud Services web portal: 1. Specify for the Redirect URL the value 'http://localhost:8877/powercli'. 2. Specify the permissions for the App (these permissions would be applied to the access tokens produced by the security context). 3. Copy the App ID and App Secret and store them in such a way that allows you to pass those values to your PowerShell script.


Copyright © VMware, Inc. All rights reserved.