public/helper/Get-TwitterOauth_Authenticate.ps1

function Get-TwitterOauth_Authenticate {
<#
.SYNOPSIS
    Authentication

.DESCRIPTION
    GET oauth/authenticate
    
    Allows a Consumer application to use an OAuth request_token to request user authorization.
    
    This method is a replacement of Section 6.2 of the OAuth 1.0 authentication flow for applications using the callback authentication flow. The method will use the currently logged in user as the account for access authorization unless the force_login parameter is set to true.
    
    This method differs from GET oauth / authorize in that if the user has already granted the application permission, the redirect will occur without the user having to re-approve the application. To realize this behavior, you must enable the Use Sign in with Twitter setting on your application record.

.PARAMETER force_login
    Forces the user to enter their credentials to ensure the correct users account is authorized.

.PARAMETER screen_name
    Prefills the username input box of the OAuth login screen with the given value.

.NOTES
    This helper function was generated by the information provided here:
    https://developer.twitter.com/en/docs/basics/authentication/api-reference/authenticate

#>

    [CmdletBinding()]
    Param(
        [string]$force_login,
        [string]$screen_name
    )
    Begin {

        [hashtable]$Parameters = $PSBoundParameters
                   $CmdletBindingParameters | ForEach-Object { $Parameters.Remove($_) }

        [string]$Method      = 'GET'
        [string]$Resource    = '/oauth/authenticate'
        [string]$ResourceUrl = 'https://api.twitter.com/oauth/authenticate'

    }
    Process {

        # Find & Replace any ResourceUrl parameters.
        $UrlParameters = [regex]::Matches($ResourceUrl, '(?<!\w):\w+')
        ForEach ($UrlParameter in $UrlParameters) {
            $UrlParameterValue = $Parameters["$($UrlParameter.Value.TrimStart(":"))"]
            $ResourceUrl = $ResourceUrl -Replace $UrlParameter.Value, $UrlParameterValue
        }

        $OAuthSettings = Get-TwitterOAuthSettings -Resource $Resource
        Invoke-TwitterAPI -Method $Method -ResourceUrl $ResourceUrl -Parameters $Parameters -OAuthSettings $OAuthSettings

    }
    End {

    }
}