microsoft / terraform-provider-power-platform

Power Platform Terraform Provider
https://registry.terraform.io/providers/microsoft/power-platform/latest/docs
MIT License
31 stars 9 forks source link

+ Refactor authentication configuration in api_client.go and auth.go #448

Closed mattdot closed 2 weeks ago

mattdot commented 2 weeks ago

This pull request refactors the authentication configuration in api_client.go and auth.go. It introduces the ProviderClient struct as a wrapper around the API client, providing additional helper methods. It also adds the GetConfig method to the ApiClient struct to retrieve the provider configuration. The TryGetScopeFromURL function now returns the authorization scope for the given API URL. The ExecuteForGivenScope method is added to execute an HTTP request with a specific scope, method, URL, headers, body, acceptable status codes, and response object. The Execute method is modified to use the TryGetScopeFromURL function and handle the response object. The RetryAfterDefault method now returns a random duration between 5 and 10 seconds. The SleepWithContext method is added to sleep for a given duration or until the context is canceled. Additionally, the providerError struct is renamed to ProviderError, and the NewProviderError and WrapIntoProviderError functions are modified to use the ProviderError struct.