Exemplo n.º 1
0
        // アプリIDの取得
        public async Task <ClientAppJson> getClientAppJson(string host)
        {
            var data     = new ClientAppJson();
            var postData = new List <KeyValuePair <string, string> >();

            postData.Add(new KeyValuePair <string, string>("client_name", "OppaiAPI"));
            postData.Add(new KeyValuePair <string, string>("redirect_uris", "urn:ietf:wg:oauth:2.0:oob"));
            postData.Add(new KeyValuePair <string, string>("scopes", DefaultValue.MSTDN_SCOPE));
            var content = new FormUrlEncodedContent(postData);

            var url = "https://" + host + DefaultValue.MSTDN_AUTHPATH;

            try {
                var response = await client.PostAsync(url, content);

                if (response.IsSuccessStatusCode)
                {
                    var json = await response.Content.ReadAsStringAsync();

                    data = JsonConvert.DeserializeObject <ClientAppJson>(json);
                }
            } catch (Exception ex) {
                throw ex;
            }
            return(data);
        }
Exemplo n.º 2
0
        // DBへ登録
        private void setAppKey(AccessSQLite db, ClientAppJson client)
        {
            var app = new AppKey();

            app.ClientId  = client.client_id;
            app.ClientSec = client.client_secret;
            db.DeleteAppKeyMaster();
            db.InsertAppKeyMaster(app);
        }