'.NET Maui iOS - System.PlatformNotSupportedException: 'Operation is not supported on this platform.' Google.Apis.Auth.OAuth2
This Library / code works fine in Xamarin Forms latest. I'm working on bringing an App over to .NET Maui and am receiving this error. Is there something about .NET Maui HTTP that is less supported than Xamarin iOS?
at System.Net.Http.NSUrlSessionHandler.get_SupportsRedirectConfiguration()
at System.Reflection.RuntimeMethodInfo.Invoke(Object , BindingFlags , Binder , Object[] , CultureInfo )
--- End of stack trace from previous location ---
at System.Net.Http.HttpClientHandler.InvokeNativeHandlerMethod(String , Object[] )
at System.Net.Http.HttpClientHandler.GetSupportsRedirectConfiguration()
at System.Net.Http.HttpClientHandler.get_SupportsRedirectConfiguration()
at Google.Apis.Http.HttpClientFactory.CreateAndConfigureClientHandler()
at Google.Apis.Http.HttpClientFactory.CreateHandler(CreateHttpClientArgs args)
at Google.Apis.Http.HttpClientFactory.CreateHttpClient(CreateHttpClientArgs args)
at Google.Apis.Auth.OAuth2.ServiceCredential..ctor(Initializer initializer)
at Google.Apis.Auth.OAuth2.ServiceAccountCredential..ctor(Initializer initializer)
at Google.Apis.Auth.OAuth2.DefaultCredentialProvider.CreateServiceAccountCredentialFromParameters(JsonCredentialParameters credentialParameters)
at Google.Apis.Auth.OAuth2.DefaultCredentialProvider.CreateDefaultCredentialFromParameters(JsonCredentialParameters credentialParameters)
at Google.Apis.Auth.OAuth2.DefaultCredentialProvider.CreateDefaultCredentialFromJson(String json)
at Google.Apis.Auth.OAuth2.GoogleCredential.FromJson(String json)
Code:
string content = File.ReadAllText("secret.json");
var credential = GoogleCredential.FromJson(content).CreateScoped(new string[] { SheetsService.Scope.Spreadsheets });
new SheetsService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|