'Webassembly Blazor - Use Google.Apis.Sheets

I have a blazor app (only client side), web assembly.

I want to read and write excel files that are on google drive, for that I am using Google.Apis.Sheets but I am not succeeding.

Below I show 3 examples of implementations that I tried to use but they all give erro

Example 1 - One or more errors occurred. (System.Net.Sockets is not supported on this platform.)

        Byte[] FileBytes = await client.GetByteArrayAsync("files/credentials2.json");
        MemoryStream stream = new MemoryStream(FileBytes);
        UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                GoogleClientSecrets.FromStream(stream).Secrets,
                Scopes,
                "user",
                CancellationToken.None).Result;

        SheetsService service = new SheetsService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = "FinantialApp",
            });

Example 2 - One or more errors occurred. (System.Net.Sockets is not supported on this platform.)

        ClientSecrets cs = new ClientSecrets
            {
                ClientId = ClientId,
                ClientSecret = ClientSecret
            };

        var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(cs, Scopes, "TEST", CancellationToken.None).Result;

        // Creating Google Sheets API service...
        SheetsService service = new SheetsService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = ApplicationName,
            });

Example 3 - System.Security.Cryptography.Algorithms is not supported on this platform.

        byte[] FileBytes = await client.GetByteArrayAsync("files/credentials1.json");
        var credential = GoogleCredential.FromStream(new MemoryStream(FileBytes))
        .CreateScoped(SheetsService.Scope.Spreadsheets)
        .CreateWithUser(ServiceAccountEmail);

        SheetsService service = new SheetsService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = ApplicationName,
            });


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source