make get_azure_token not ARM-specific

This commit is contained in:
hong-revo 2018-11-09 16:54:48 +11:00
Родитель d20534e5c7
Коммит e539c8bbf2
1 изменённых файлов: 5 добавлений и 4 удалений

Просмотреть файл

@ -116,7 +116,7 @@ private=list(
#' @param app Your client/app ID which you registered in AAD.
#' @param auth_type The authentication type, either `"client_credentials"` or `"device_code"`.
#' @param password Your password. Required for `auth_type == "client_credentials"`, ignored for `auth_type == "device_code"`.
#' @param arm_host URL for your Azure Resource Manager host. For the public Azure cloud, this is `https://management.azure.com/`.
#' @param resource_host URL for your resource host. For Resource Manager in the public Azure cloud, this is `https://management.azure.com/`.
#'
#' @details
#' This function does much the same thing as [httr::oauth2.0_token()], but with support for device authentication and with unnecessary options removed. Device authentication removes the need to save a password on your machine. Instead, the server provides you with a code, along with a URL. You then visit the URL in your browser and enter the code, which completes the authentication process.
@ -126,13 +126,14 @@ private=list(
#' [OAuth authentication for Azure Active Directory](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-protocols-oauth-code),
#' [Device code flow on OAuth.com](https://www.oauth.com/oauth2-servers/device-flow/token-request/)
#' @export
get_azure_token=function(aad_host, tenant, app, auth_type=c("client_credentials", "device_code"), password, arm_host)
get_azure_token=function(aad_host, tenant, app, auth_type=c("client_credentials", "device_code"),
password, resource_host)
{
auth_type <- match.arg(auth_type)
base_url <- construct_path(aad_host, tenant)
if(auth_type == "client_credentials")
auth_with_creds(base_url, app, password, arm_host)
else auth_with_device(base_url, app, arm_host)
auth_with_creds(base_url, app, password, resource_host)
else auth_with_device(base_url, app, resource_host)
}