From 4d28aca671454e9a50d5bbdaa9e471ea11187a7c Mon Sep 17 00:00:00 2001 From: qgarnier Date: Thu, 19 Nov 2020 15:43:56 +0100 Subject: [PATCH] better management of azure password (#2354) --- cloud/azure/custom/api.pm | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/cloud/azure/custom/api.pm b/cloud/azure/custom/api.pm index a7763b503..ac1f8ffd2 100644 --- a/cloud/azure/custom/api.pm +++ b/cloud/azure/custom/api.pm @@ -159,20 +159,18 @@ sub get_access_token { my $access_token = $options{statefile}->get(name => 'access_token'); if ($has_cache_file == 0 || !defined($access_token) || (($expires_on - time()) < 10)) { - my $uri = URI::Encode->new({encode_reserved => 1}); - my $encoded_management_endpoint = $uri->encode($self->{management_endpoint}); - my $post_data = 'grant_type=client_credentials' . - '&client_id=' . $self->{client_id} . - '&client_secret=' . $self->{client_secret} . - '&resource=' . $encoded_management_endpoint; - $self->settings(); my $content = $self->{http}->request( - method => 'POST', query_form_post => $post_data, + method => 'POST', full_url => $self->{login_endpoint} . '/' . $self->{tenant} . '/oauth2/token', hostname => '', - header => [ 'Content-Type: application/x-www-form-urlencoded' ] + post_param => [ + 'grant_type=client_credentials', + 'client_id=' . $self->{client_id}, + 'client_secret=' . $self->{client_secret}, + 'resource=' . $self->{management_endpoint} + ] ); if (!defined($content) || $content eq '' || $self->{http}->get_header(name => 'content-length') == 0) {