Xamarin Forms IOS Google Sheets API:client_secret.json ファイルが見つかりません

Xamarin Forms IOS Google Sheets API の解決策:client_secret.json ファイルが見つかりません
以下に示します:

xamarin フォーム ios プロジェクトで Google シート データを読み込もうとしています。このチュートリアルに従いました:https://www.youtube.com/watch?v=afTiNU6EoA8&t=325s
役に立たなかった.

プログラムで client_secret.json ファイルが見つからないと表示され、問題の解決策が見つかりません。

この例外エラーが表示されます

これが私のコードです:

using System;
using Google.Apis.Sheets.v4;
using Google.Apis.Auth.OAuth2;
using System.IO;
using Google.Apis.Services;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace CUapp
{

public class GoogleSheets
{
    static readonly string[] Scopes = { SheetsService.Scope.Spreadsheets };
    static readonly string SpreadsheetId = "1Me8q2o54xphoO_L1l-aK6_qzwIX2AAmmZzCCxvmGbl8";
    static readonly string ApplicationName = "CUapp";
    static readonly string sheet = "Sheet1";
    static SheetsService service;



    public GoogleSheets()
    {
        GoogleCredential credential;
        using (
            var stream = new FileStream("client_secret.json", FileMode.Open, FileAccess.Read))
        //var stream = Assembly.GetManifestResourceStream("client_secret.json"))
        {
            credential = GoogleCredential.FromStream(stream)
                .CreateScoped(Scopes);
        }

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

    static public void ReadEntries()
    {
        var range = $"{sheet}!B1:B30";
        SpreadsheetsResource.ValuesResource.GetRequest request = service.Spreadsheets.Values.Get(SpreadsheetId, range);
        request.MajorDimension = SpreadsheetsResource.ValuesResource.GetRequest.MajorDimensionEnum.COLUMNS;

        var response = request.Execute();
        var values = response.Values;

        if (values != null && values.Count > 0)
        {
            foreach (var column in values)
            {
                string title = (string)column[0];

                int i = (int)column[1];

                //string buttonImg = $"{title}.jpeg";


                //labels
                char[] seperator = new char[] { ' ', ',' };
                string labels_ = (string)column[3];
                List<string> labels = labels_.Split(seperator, StringSplitOptions.RemoveEmptyEntries).ToList();

                //_nums
                int ingredients_num = (int)column[4];
                int howto_num = (int)column[5];
                int nutritionTips_num = (int)column[6];
                int cookingTips_num = (int)column[7];

                //ingredients
                List<string> ingredients_raw = (List<string>)column.Skip(8).Take(ingredients_num);
                List<ingredientBlock> ingredients = new List<ingredientBlock>();

                foreach (var value_raw in ingredients_raw)
                {
                    ingredientBlock ingredient = new ingredientBlock { text = value_raw };
                    ingredients.Add(ingredient);
                }

                //howto
                List<string> howto_raw = (List<string>)column.Skip(8 + 1 + ingredients_num).Take(howto_num);
                List<ingredientBlock> howto = new List<ingredientBlock>();
                char howtoSeperator="#";

                foreach (string value_raw in howto_raw)
                {
                    var value = value_raw.Split(howtoSeperator).ToList();

                    ingredientBlock ingredient = new ingredientBlock { step = value[0], text = value[1] };

                    howto.Add(ingredient);
                }


                recipeList.list.Add(new recipeModel { title = title, howto = howto, i = i, ingredients = ingredients, labels = labels });

                //nutritionTips

                //cookingTips_ 

                // create new recipemodel
                // title = 0, index = 1, buttonImg = 2, labels = 3
                // ingredients_num = 4, methods_num = 5, nutritionTips_num = 6
                // cookingTips_num = 7, ingredients = 8:8+ingredients_num-1, 
            }
        }



    }
}
}

どんな反応でも大歓迎です😀

まず、client_secret.json ファイルを共有コードに配置し、Build Action を EmbeddedResource に設定してください。

次に、次のコードを使用して、ローカルの json ファイルを解析します。

var assembly = typeof(listviewsample.Page24).GetTypeInfo().Assembly;
        Stream stream = assembly.GetManifestResourceStream("FormsSample.user.json");
        using (var reader = new System.IO.StreamReader(stream))
        {
            var jsonString = reader.ReadToEnd();
           //........
        }

更新:

簡単なサンプルでコードをテストします。次のスクリーンショットをご覧ください。

 public partial class Page2 : ContentPage
{
    public Page2()
    {
        InitializeComponent();
        var assembly = typeof(Page2).GetTypeInfo().Assembly;
        Stream stream = assembly.GetManifestResourceStream("mediasample.user.json");
        using (var reader = new System.IO.StreamReader(stream))
        {
            var jsonString = reader.ReadToEnd();

            //Converting JSON Array Objects into generic list                             

        }
    }
}

スクリーンショット:

Cherry BUのおかげで、このハードルを乗り越えることができました。これが私のコードです:

public GoogleSheets()
    {
        GoogleCredential credential;

        var assembly = typeof(GoogleSheets).GetTypeInfo().Assembly;
        Stream stream = assembly.GetManifestResourceStream("CUapp.client_secret.json");
        using (var reader = new StreamReader(stream))
        {
           
            credential = GoogleCredential.FromStream(stream)
            .CreateScoped(Scopes);
        }

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