This commit is contained in:
Ryutaro Koma 2016-04-19 12:53:14 +09:00
Родитель b9ac51a477
Коммит 1ba2a4d30d
30 изменённых файлов: 14694 добавлений и 376 удалений

1
CONTRIBUTING.md Normal file
Просмотреть файл

@ -0,0 +1 @@
We're not ready to accept contributions at this time, but if you have any feedback, please post to the Issues list. Thanks!

8
LICENSE.txt Normal file
Просмотреть файл

@ -0,0 +1,8 @@
The MIT License (MIT)
Copyright (c) 2016 Microsoft
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

5
Office365APIEditor/GetCodeForm.Designer.cs сгенерированный
Просмотреть файл

@ -28,6 +28,7 @@
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GetCodeForm));
this.webBrowser1 = new System.Windows.Forms.WebBrowser();
this.SuspendLayout();
//
@ -47,6 +48,10 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(566, 705);
this.Controls.Add(this.webBrowser1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "GetCodeForm";
this.Load += new System.EventHandler(this.GetCodeForm_Load);
this.ResumeLayout(false);

Просмотреть файл

@ -1,4 +1,7 @@
using System;
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
@ -14,16 +17,18 @@ namespace Office365APIEditor
public partial class GetCodeForm : Form
{
private string redirectUrl;
private string AuthenticationUrl;
private string authenticationUrl;
private string acquiredCode = "";
// Return value
private string _acquiredCode = "";
public GetCodeForm(string ClientID, string RedirectUri, string ResourceUri)
{
InitializeComponent();
redirectUrl = RedirectUri;
AuthenticationUrl = "https://login.windows.net/common/oauth2/authorize?response_type=code&client_id=" + ClientID + "&redirect_uri=" + System.Web.HttpUtility.UrlEncode(RedirectUri) + "&resource=" + System.Web.HttpUtility.UrlEncode(ResourceUri) + "&prompt=login";
// Build an URL of sign-in page.
authenticationUrl = "https://login.windows.net/common/oauth2/authorize?response_type=code&client_id=" + ClientID + "&redirect_uri=" + System.Web.HttpUtility.UrlEncode(RedirectUri) + "&resource=" + System.Web.HttpUtility.UrlEncode(ResourceUri) + "&prompt=login";
webBrowser1.DocumentTitleChanged += new EventHandler(webBrowser1_DocumentTitleChanged);
}
@ -35,27 +40,35 @@ namespace Office365APIEditor
private void GetCodeForm_Load(object sender, EventArgs e)
{
webBrowser1.Navigate(AuthenticationUrl);
// Navigate to the sing-in page.
webBrowser1.Navigate(authenticationUrl);
}
private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
if ((e.Url.AbsoluteUri.StartsWith(redirectUrl)) && (e.Url.AbsoluteUri.Contains("code")))
// Check whether the URL is RedirectUrl.
if ((e.Url.AbsoluteUri.ToLower().StartsWith(redirectUrl.ToLower())) && (e.Url.AbsoluteUri.Contains("code")))
{
// Get the Authorization Code from a query string.
var queryString = e.Url.AbsoluteUri.Substring(e.Url.AbsoluteUri.IndexOf("?"));
NameValueCollection temp = System.Web.HttpUtility.ParseQueryString(queryString);
acquiredCode = temp["code"];
_acquiredCode = temp["code"];
this.DialogResult = DialogResult.OK;
this.Close();
}
// If we couldn't get the Authorization Code, do nothing.
// Authorization is in progress, or error messages is displayed on the page.
}
public DialogResult ShowDialog(out string code)
{
DialogResult result = this.ShowDialog();
code = acquiredCode;
code = _acquiredCode;
return result;
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,21 +1,27 @@
 Properties.Settings.Default["LastWebAppClientID"] = "6c8439d0-6144-4b63-a766-fa796fa2779c";
Properties.Settings.Default["LastWebAppRedirectURL"] = "http://localhost/app03";
Properties.Settings.Default["LastWebAppClientSecret"] = "3HasFgH9XLouiCvC6I9NJqRFirvRELbGjAIRQ6rqN2w=";
Web Application (rykoma02)
Client ID : 6c8439d0-6144-4b63-a766-fa796fa2779c
Redirect URL : http://localhost/app03
Resource : Exchange Online (Microsoft Graph でも可)
Client Secret : 3HasFgH9XLouiCvC6I9NJqRFirvRELbGjAIRQ6rqN2w=
99bef61c-f239-4544-b869-51dbf50a6960
http://localhost/webapp01
kr5KGgq12M4L8t5Te1uaZ5Np7KkkdpFuFe5QkvmSRQ4=
Web Application (rykoma03)
Client ID : 072e0ce2-c143-4f05-8b3a-9700e1e23387
Redirect URL : http://localhost/webapp02
Resource : Exchange Online
Client Secret : wc/0CiCk1AI2N57HC6G81vjBKtWefRyKNHxTuBx7k1M=
Native Application (rykoma02)
Tenant Name rykoma02.onmicrosoft.com
Client ID : c5524f44-7719-4b68-a1e5-ce434b1862bd
Resource : Exchange Online (Microsoft Graph でも可)
Redirect URL : http://localhost/restoauth01
Properties.Settings.Default["LastNativeAppTenantName"] = "rykoma02.onmicrosoft.com";
Properties.Settings.Default["LastNativeAppClientID"] = "c5524f44-7719-4b68-a1e5-ce434b1862bd";
Properties.Settings.Default["LastNativeAppRedirectURL"] = "http://localhost/restoauth01";
https://outlook.office.com/api/v2.0/me/calendarview?startDateTime=2016-03-01T00:00:00&endDateTime=2016-03-01T23:59:59
GET
https://outlook.office.com/api/v2.0/me/calendarview?startDateTime=2016-03-01T00:00:00&endDateTime=2016-03-01T23:59:59
POST
https://outlook.office.com/api/v2.0/me/sendmail
{
"Message": {
@ -43,4 +49,22 @@ https://outlook.office.com/api/v2.0/me/sendmail
}
a
GET
https://outlook.office.com/api/v2.0/me/MailFolders/Inbox/messages/?$select=Id&$top=1
DELETE
https://outlook.office.com/api/v2.0/me/messages/{message_id}
PATCH
https://outlook.office.com/api/v2.0/me/messages/{message_id}
{
"Categories": [
"Orange category",
"Green category"
],
"IsRead": true
}

Просмотреть файл

@ -31,6 +31,9 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>image.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.24.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.24.304111323\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
@ -110,7 +113,7 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Content Include="License.txt" />
<Content Include="image.ico" />
<Content Include="Licenses\Microsoft.IdentityModel.Clients.ActiveDirectory.txt" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

Просмотреть файл

@ -1,4 +1,7 @@
using System;
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
@ -16,6 +19,8 @@ namespace Office365APIEditor
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
// Start RequestForm. RequestForm will launch StartFrom.
Application.Run(new RequestForm());
}
}

Просмотреть файл

@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Office365APIEditor")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyCopyright("Copyright (c) 2016 Microsoft")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.0.1")]
[assembly: AssemblyFileVersion("0.1.0.1")]
[assembly: AssemblyVersion("0.2.0.0")]
[assembly: AssemblyFileVersion("0.2.0.0")]

2
Office365APIEditor/RequestForm.Designer.cs сгенерированный
Просмотреть файл

@ -28,6 +28,7 @@
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RequestForm));
this.label1 = new System.Windows.Forms.Label();
this.textBox_Result = new System.Windows.Forms.TextBox();
this.button_Run = new System.Windows.Forms.Button();
@ -247,6 +248,7 @@
this.Controls.Add(this.textBox_Result);
this.Controls.Add(this.button_Run);
this.Controls.Add(this.textBox_Request);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MinimumSize = new System.Drawing.Size(836, 486);
this.Name = "RequestForm";
this.Text = "Office365APIEditor";

Просмотреть файл

@ -1,4 +1,7 @@
using System;
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
using System;
using System.Collections;
using System.Globalization;
using System.IO;
@ -22,11 +25,15 @@ namespace Office365APIEditor
private void RequestForm_Load(object sender, EventArgs e)
{
// First of all, we have to get an access token.
StartForm startForm = new StartForm();
if (startForm.ShowDialog(out _tokenResponse, out _resource, out _clientID, out _clientSecret) == DialogResult.OK)
{
if (_tokenResponse.access_token.StartsWith("USEBASICBASIC"))
{
// Basic auth
useBasicAuth = true;
textBox_BasicAuthSMTPAddress.Enabled = true;
textBox_BasicAuthPassword.Enabled = true;
@ -34,6 +41,8 @@ namespace Office365APIEditor
}
else
{
// OAuth
useBasicAuth = false;
textBox_BasicAuthSMTPAddress.Enabled = false;
textBox_BasicAuthSMTPAddress.Text = "OAuth (" + _resource + ")";
@ -51,40 +60,37 @@ namespace Office365APIEditor
private void button_Run_Click(object sender, EventArgs e)
{
//文字コードを指定する
Encoding enc = Encoding.Default;
System.Net.WebRequest req = System.Net.WebRequest.Create(textBox_Request.Text);
System.Net.WebRequest request = System.Net.WebRequest.Create(textBox_Request.Text);
request.ContentType = "application/json";
if (useBasicAuth == true)
{
// Basic authentication
string cred = Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(textBox_BasicAuthSMTPAddress.Text + ":" + textBox_BasicAuthPassword.Text));
req.Headers.Add("Authorization:Basic " + cred);
string credential = Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(textBox_BasicAuthSMTPAddress.Text + ":" + textBox_BasicAuthPassword.Text));
request.Headers.Add("Authorization:Basic " + credential);
}
else
{
// OAuth authentication
req.Headers.Add("Authorization:Bearer " + _tokenResponse.access_token);
request.Headers.Add("Authorization:Bearer " + _tokenResponse.access_token);
}
if (radioButton_GET.Checked)
{
// Request is GET.
req.Method = "GET";
req.ContentType = "application/json";
request.Method = "GET";
}
else if (radioButton_POST.Checked)
{
// Request is POST.
req.Method = "POST";
req.ContentType = "application/json";
request.Method = "POST";
using (var streamWriter = new StreamWriter(req.GetRequestStream()))
// Build a body.
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
{
string json = textBox_RequestBody.Text;
string body = textBox_RequestBody.Text;
streamWriter.Write(json);
streamWriter.Write(body);
streamWriter.Flush();
streamWriter.Close();
}
@ -92,14 +98,14 @@ namespace Office365APIEditor
else if (radioButton_PATCH.Checked)
{
// Request if PATCH
req.Method = "PATCH";
req.ContentType = "application/json";
request.Method = "PATCH";
using (var streamWriter = new StreamWriter(req.GetRequestStream()))
// Build a body.
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
{
string json = textBox_RequestBody.Text;
string body = textBox_RequestBody.Text;
streamWriter.Write(json);
streamWriter.Write(body);
streamWriter.Flush();
streamWriter.Close();
}
@ -107,8 +113,7 @@ namespace Office365APIEditor
else
{
// Request is DELETE.
req.Method = "DELETE";
req.ContentType = "application/json";
request.Method = "DELETE";
}
try
@ -116,22 +121,22 @@ namespace Office365APIEditor
// Change cursor.
this.Cursor = Cursors.WaitCursor;
//サーバーからの応答を受信するためのWebResponseを取得
System.Net.HttpWebResponse res = (System.Net.HttpWebResponse)req.GetResponse();
//応答データを受信するためのStreamを取得
// Get a response and response stream.
System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();
string jsonResponse = "";
using (System.IO.Stream resStream = res.GetResponseStream())
using (Stream responseStream = response.GetResponseStream())
{
System.IO.StreamReader sr = new System.IO.StreamReader(resStream, enc);
jsonResponse = sr.ReadToEnd();
StreamReader reader = new StreamReader(responseStream, Encoding.Default);
jsonResponse = reader.ReadToEnd();
}
// Display the results.
textBox_Result.Text = "StatusCode : " + res.StatusCode.ToString() + "\r\n\r\n";
textBox_Result.Text += "Response Header : \r\n" + res.Headers.ToString() + "\r\n\r\n";
textBox_Result.Text = "StatusCode : " + response.StatusCode.ToString() + "\r\n\r\n";
textBox_Result.Text += "Response Header : \r\n" + response.Headers.ToString() + "\r\n\r\n";
// JSON をパースして読みやすくする。
textBox_Result.Text = parseJson(jsonResponse);
// Parse the JSON data.
textBox_Result.Text += parseJson(jsonResponse);
// Save application setting.
Properties.Settings.Default.Save();
@ -153,6 +158,7 @@ namespace Office365APIEditor
private void textBox_Request_KeyDown(object sender, KeyEventArgs e)
{
// Enable 'Ctrl + A'
if (e.Control && e.KeyCode == Keys.A)
{
textBox_Request.SelectAll();
@ -161,6 +167,7 @@ namespace Office365APIEditor
private void textBox_RequestBody_KeyDown(object sender, KeyEventArgs e)
{
// Enable 'Ctrl + A'
if (e.Control && e.KeyCode == Keys.A)
{
textBox_RequestBody.SelectAll();
@ -169,6 +176,7 @@ namespace Office365APIEditor
private void textBox_Result_KeyDown(object sender, KeyEventArgs e)
{
// Enable 'Ctrl + A'
if (e.Control && e.KeyCode == Keys.A)
{
textBox_Result.SelectAll();
@ -184,72 +192,64 @@ namespace Office365APIEditor
{
// Request another access token with refresh token.
//文字コードを指定する
Encoding enc = Encoding.Default;
// string resourceURL = StartForm.GetResourceURL(_resource);
string resourceURL = StartForm.GetResourceURL(_resource);
//POST送信する文字列を作成
string param = "";
Hashtable ht = new Hashtable();
// Build a POST body.
string postBody = "";
Hashtable tempTable = new Hashtable();
ht["grant_type"] = "refresh_token";
ht["refresh_token"] = _tokenResponse.refresh_token;
ht["resource"] = System.Web.HttpUtility.UrlEncode(resourceURL);
tempTable["grant_type"] = "refresh_token";
tempTable["refresh_token"] = _tokenResponse.refresh_token;
tempTable["resource"] = System.Web.HttpUtility.UrlEncode(resourceURL);
if (_clientID != "")
{
// If _clientID has value, we're working with web app.
ht["client_id"] = _clientID;
ht["client_secret"] = _clientSecret;
// So we have to add Client ID and Client Secret.
tempTable["client_id"] = _clientID;
tempTable["client_secret"] = _clientSecret;
}
foreach (string k in ht.Keys)
foreach (string key in tempTable.Keys)
{
param += String.Format("{0}={1}&", k, ht[k]);
postBody += String.Format("{0}={1}&", key, tempTable[key]);
}
byte[] postDataBytes = Encoding.ASCII.GetBytes(param);
byte[] postDataBytes = Encoding.ASCII.GetBytes(postBody);
//WebRequestの作成
System.Net.WebRequest req = System.Net.WebRequest.Create("https://login.windows.net/common/oauth2/token/");
//メソッドにPOSTを指定
req.Method = "POST";
//ContentTypeを"application/x-www-form-urlencoded"にする
req.ContentType = "application/x-www-form-urlencoded";
//POST送信するデータの長さを指定
req.ContentLength = postDataBytes.Length;
System.Net.WebRequest request = System.Net.WebRequest.Create("https://login.windows.net/common/oauth2/token/");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = postDataBytes.Length;
try
{
// Change a cursor.
this.Cursor = Cursors.WaitCursor;
//データをPOST送信するためのStreamを取得
using (System.IO.Stream reqStream = req.GetRequestStream())
// Get a RequestStream to POST a data.
using (Stream reqStream = request.GetRequestStream())
{
//送信するデータを書き込む
reqStream.Write(postDataBytes, 0, postDataBytes.Length);
}
//サーバーからの応答を受信するためのWebResponseを取得
System.Net.HttpWebResponse res = (System.Net.HttpWebResponse)req.GetResponse();
//応答データを受信するためのStreamを取得
string jsonResponse = "";
using (System.IO.Stream resStream = res.GetResponseStream())
System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();
using (Stream responseStream = response.GetResponseStream())
{
System.IO.StreamReader sr = new System.IO.StreamReader(resStream, enc);
jsonResponse = sr.ReadToEnd();
StreamReader reader = new StreamReader(responseStream, Encoding.Default);
jsonResponse = reader.ReadToEnd();
}
// Display the results.
textBox_Result.Text = "StatusCode : " + res.StatusCode.ToString() + "\r\n\r\n";
textBox_Result.Text += "Response Header : \r\n" + res.Headers.ToString() + "\r\n\r\n";
textBox_Result.Text = "StatusCode : " + response.StatusCode.ToString() + "\r\n\r\n";
textBox_Result.Text += "Response Header : \r\n" + response.Headers.ToString() + "\r\n\r\n";
// JSON をパースして読みやすくする。
textBox_Result.Text = parseJson(jsonResponse);
// Parse the JSON data.
textBox_Result.Text += parseJson(jsonResponse);
// デシリアライズして Access Token を取得
// Deserialize and get Access Token.
_tokenResponse = StartForm.Deserialize<TokenResponse>(jsonResponse);
}
catch (System.Net.WebException ex)
@ -283,15 +283,18 @@ namespace Office365APIEditor
if (textEnum.Current.ToString() == ",")
{
// If ',' appreared, add new line.
parsedData.Append(textEnum.Current + "\r\n" + CreateTabString(indentCount));
}
else if (textEnum.Current.ToString() == "{")
{
// If '{' appreared, add new new line and increment indentCount by 1.
indentCount += 1;
parsedData.Append(textEnum.Current + "\r\n" + CreateTabString(indentCount));
}
else if (textEnum.Current.ToString() == "}")
{
// If '}' appreared, decrement indentCount by 1.
indentCount -= 1;
parsedData.Append(textEnum.Current);
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

272
Office365APIEditor/StartForm.Designer.cs сгенерированный
Просмотреть файл

@ -28,9 +28,13 @@
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(StartForm));
this.button_Cancel = new System.Windows.Forms.Button();
this.button_NativeAppAcquireAccessToken = new System.Windows.Forms.Button();
this.groupBox_NativeApp = new System.Windows.Forms.GroupBox();
this.label20 = new System.Windows.Forms.Label();
this.label19 = new System.Windows.Forms.Label();
this.label18 = new System.Windows.Forms.Label();
this.radioButton_NativeAppGraphResource = new System.Windows.Forms.RadioButton();
this.label13 = new System.Windows.Forms.Label();
this.textBox_NativeAppRedirectUri = new System.Windows.Forms.TextBox();
@ -41,9 +45,12 @@
this.radioButton_NativeAppExoResource = new System.Windows.Forms.RadioButton();
this.label14 = new System.Windows.Forms.Label();
this.groupBox_WebApp = new System.Windows.Forms.GroupBox();
this.button_WebAppAcquireAccessToken = new System.Windows.Forms.Button();
this.label16 = new System.Windows.Forms.Label();
this.label17 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.radioButton_WebAppGraphResource = new System.Windows.Forms.RadioButton();
this.textBox_WebAppCode = new System.Windows.Forms.TextBox();
this.button_WebAppGetCode = new System.Windows.Forms.Button();
this.label6 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.textBox_WebAppClientSecret = new System.Windows.Forms.TextBox();
this.label10 = new System.Windows.Forms.Label();
@ -56,18 +63,9 @@
this.radioButton_WebApp = new System.Windows.Forms.RadioButton();
this.radioButton_BasicAuth = new System.Windows.Forms.RadioButton();
this.groupBox_BasicAuth = new System.Windows.Forms.GroupBox();
this.button_BasicAuthGoNext = new System.Windows.Forms.Button();
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.label15 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.label16 = new System.Windows.Forms.Label();
this.label17 = new System.Windows.Forms.Label();
this.button_WebAppAcquireAccessToken = new System.Windows.Forms.Button();
this.label18 = new System.Windows.Forms.Label();
this.label19 = new System.Windows.Forms.Label();
this.label20 = new System.Windows.Forms.Label();
this.button_BasicAuthGoNext = new System.Windows.Forms.Button();
this.groupBox_NativeApp.SuspendLayout();
this.groupBox_WebApp.SuspendLayout();
this.groupBox_BasicAuth.SuspendLayout();
@ -76,10 +74,10 @@
// button_Cancel
//
this.button_Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button_Cancel.Location = new System.Drawing.Point(436, 622);
this.button_Cancel.Location = new System.Drawing.Point(436, 559);
this.button_Cancel.Name = "button_Cancel";
this.button_Cancel.Size = new System.Drawing.Size(75, 23);
this.button_Cancel.TabIndex = 33;
this.button_Cancel.TabIndex = 50;
this.button_Cancel.Text = "Cancel";
this.button_Cancel.UseVisualStyleBackColor = true;
this.button_Cancel.Click += new System.EventHandler(this.button_Cancel_Click);
@ -87,10 +85,10 @@
// button_NativeAppAcquireAccessToken
//
this.button_NativeAppAcquireAccessToken.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button_NativeAppAcquireAccessToken.Location = new System.Drawing.Point(6, 158);
this.button_NativeAppAcquireAccessToken.Location = new System.Drawing.Point(9, 158);
this.button_NativeAppAcquireAccessToken.Name = "button_NativeAppAcquireAccessToken";
this.button_NativeAppAcquireAccessToken.Size = new System.Drawing.Size(130, 23);
this.button_NativeAppAcquireAccessToken.TabIndex = 32;
this.button_NativeAppAcquireAccessToken.TabIndex = 14;
this.button_NativeAppAcquireAccessToken.Text = "Acquire Access Token";
this.button_NativeAppAcquireAccessToken.UseVisualStyleBackColor = true;
this.button_NativeAppAcquireAccessToken.Click += new System.EventHandler(this.button_NativeAppAcquireAccessToken_Click);
@ -111,20 +109,47 @@
this.groupBox_NativeApp.Controls.Add(this.radioButton_NativeAppExoResource);
this.groupBox_NativeApp.Controls.Add(this.label14);
this.groupBox_NativeApp.Enabled = false;
this.groupBox_NativeApp.Location = new System.Drawing.Point(26, 320);
this.groupBox_NativeApp.Location = new System.Drawing.Point(26, 270);
this.groupBox_NativeApp.Name = "groupBox_NativeApp";
this.groupBox_NativeApp.Size = new System.Drawing.Size(485, 190);
this.groupBox_NativeApp.TabIndex = 31;
this.groupBox_NativeApp.TabStop = false;
this.groupBox_NativeApp.Text = "Native application settings";
//
// label20
//
this.label20.AutoSize = true;
this.label20.Location = new System.Drawing.Point(175, 130);
this.label20.Name = "label20";
this.label20.Size = new System.Drawing.Size(10, 13);
this.label20.TabIndex = 34;
this.label20.Text = " ";
//
// label19
//
this.label19.AutoSize = true;
this.label19.Location = new System.Drawing.Point(6, 142);
this.label19.Name = "label19";
this.label19.Size = new System.Drawing.Size(155, 13);
this.label19.TabIndex = 34;
this.label19.Text = "Step 2 : Acquire Access Token";
//
// label18
//
this.label18.AutoSize = true;
this.label18.Location = new System.Drawing.Point(6, 16);
this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(121, 13);
this.label18.TabIndex = 34;
this.label18.Text = "Step 1 : Fill out the form.";
//
// radioButton_NativeAppGraphResource
//
this.radioButton_NativeAppGraphResource.AutoSize = true;
this.radioButton_NativeAppGraphResource.Location = new System.Drawing.Point(290, 110);
this.radioButton_NativeAppGraphResource.Name = "radioButton_NativeAppGraphResource";
this.radioButton_NativeAppGraphResource.Size = new System.Drawing.Size(100, 17);
this.radioButton_NativeAppGraphResource.TabIndex = 30;
this.radioButton_NativeAppGraphResource.TabIndex = 13;
this.radioButton_NativeAppGraphResource.Text = "Microsoft Graph";
this.radioButton_NativeAppGraphResource.UseVisualStyleBackColor = true;
//
@ -143,7 +168,7 @@
this.textBox_NativeAppRedirectUri.Location = new System.Drawing.Point(178, 84);
this.textBox_NativeAppRedirectUri.Name = "textBox_NativeAppRedirectUri";
this.textBox_NativeAppRedirectUri.Size = new System.Drawing.Size(295, 20);
this.textBox_NativeAppRedirectUri.TabIndex = 29;
this.textBox_NativeAppRedirectUri.TabIndex = 11;
this.textBox_NativeAppRedirectUri.Text = global::Office365APIEditor.Properties.Settings.Default.LastNativeAppRedirectURL;
//
// label12
@ -170,7 +195,7 @@
this.textBox_NativeAppClientID.Location = new System.Drawing.Point(178, 58);
this.textBox_NativeAppClientID.Name = "textBox_NativeAppClientID";
this.textBox_NativeAppClientID.Size = new System.Drawing.Size(295, 20);
this.textBox_NativeAppClientID.TabIndex = 27;
this.textBox_NativeAppClientID.TabIndex = 10;
this.textBox_NativeAppClientID.Text = global::Office365APIEditor.Properties.Settings.Default.LastNativeAppClientID;
//
// textBox_NativeAppTenantName
@ -179,7 +204,7 @@
this.textBox_NativeAppTenantName.Location = new System.Drawing.Point(178, 32);
this.textBox_NativeAppTenantName.Name = "textBox_NativeAppTenantName";
this.textBox_NativeAppTenantName.Size = new System.Drawing.Size(295, 20);
this.textBox_NativeAppTenantName.TabIndex = 18;
this.textBox_NativeAppTenantName.TabIndex = 9;
this.textBox_NativeAppTenantName.Text = global::Office365APIEditor.Properties.Settings.Default.LastNativeAppTenantName;
//
// radioButton_NativeAppExoResource
@ -189,7 +214,7 @@
this.radioButton_NativeAppExoResource.Location = new System.Drawing.Point(178, 110);
this.radioButton_NativeAppExoResource.Name = "radioButton_NativeAppExoResource";
this.radioButton_NativeAppExoResource.Size = new System.Drawing.Size(106, 17);
this.radioButton_NativeAppExoResource.TabIndex = 19;
this.radioButton_NativeAppExoResource.TabIndex = 12;
this.radioButton_NativeAppExoResource.TabStop = true;
this.radioButton_NativeAppExoResource.Text = "Exchange Online";
this.radioButton_NativeAppExoResource.UseVisualStyleBackColor = true;
@ -208,11 +233,8 @@
this.groupBox_WebApp.Controls.Add(this.button_WebAppAcquireAccessToken);
this.groupBox_WebApp.Controls.Add(this.label16);
this.groupBox_WebApp.Controls.Add(this.label17);
this.groupBox_WebApp.Controls.Add(this.label15);
this.groupBox_WebApp.Controls.Add(this.label9);
this.groupBox_WebApp.Controls.Add(this.radioButton_WebAppGraphResource);
this.groupBox_WebApp.Controls.Add(this.textBox_WebAppCode);
this.groupBox_WebApp.Controls.Add(this.button_WebAppGetCode);
this.groupBox_WebApp.Controls.Add(this.label6);
this.groupBox_WebApp.Controls.Add(this.label2);
this.groupBox_WebApp.Controls.Add(this.textBox_WebAppClientSecret);
@ -224,38 +246,67 @@
this.groupBox_WebApp.Controls.Add(this.textBox_WebAppRedirectUri);
this.groupBox_WebApp.Location = new System.Drawing.Point(26, 35);
this.groupBox_WebApp.Name = "groupBox_WebApp";
this.groupBox_WebApp.Size = new System.Drawing.Size(485, 243);
this.groupBox_WebApp.Size = new System.Drawing.Size(485, 193);
this.groupBox_WebApp.TabIndex = 29;
this.groupBox_WebApp.TabStop = false;
this.groupBox_WebApp.Text = "Web application settings";
//
// button_WebAppAcquireAccessToken
//
this.button_WebAppAcquireAccessToken.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button_WebAppAcquireAccessToken.Location = new System.Drawing.Point(9, 159);
this.button_WebAppAcquireAccessToken.Name = "button_WebAppAcquireAccessToken";
this.button_WebAppAcquireAccessToken.Size = new System.Drawing.Size(130, 23);
this.button_WebAppAcquireAccessToken.TabIndex = 7;
this.button_WebAppAcquireAccessToken.Text = "Acquire Access Token";
this.button_WebAppAcquireAccessToken.UseVisualStyleBackColor = true;
this.button_WebAppAcquireAccessToken.Click += new System.EventHandler(this.button_WebAppAcquireAccessToken_Click);
//
// label16
//
this.label16.AutoSize = true;
this.label16.Location = new System.Drawing.Point(6, 143);
this.label16.Name = "label16";
this.label16.Size = new System.Drawing.Size(155, 13);
this.label16.TabIndex = 33;
this.label16.Text = "Step 2 : Acquire Access Token";
//
// label17
//
this.label17.AutoSize = true;
this.label17.Location = new System.Drawing.Point(181, 184);
this.label17.Name = "label17";
this.label17.Size = new System.Drawing.Size(10, 13);
this.label17.TabIndex = 32;
this.label17.Text = " ";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(6, 16);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(121, 13);
this.label9.TabIndex = 31;
this.label9.Text = "Step 1 : Fill out the form.";
//
// radioButton_WebAppGraphResource
//
this.radioButton_WebAppGraphResource.AutoSize = true;
this.radioButton_WebAppGraphResource.Location = new System.Drawing.Point(290, 84);
this.radioButton_WebAppGraphResource.Name = "radioButton_WebAppGraphResource";
this.radioButton_WebAppGraphResource.Size = new System.Drawing.Size(100, 17);
this.radioButton_WebAppGraphResource.TabIndex = 25;
this.radioButton_WebAppGraphResource.TabIndex = 5;
this.radioButton_WebAppGraphResource.Text = "Microsoft Graph";
this.radioButton_WebAppGraphResource.UseVisualStyleBackColor = true;
//
// textBox_WebAppCode
// label6
//
this.textBox_WebAppCode.Enabled = false;
this.textBox_WebAppCode.Location = new System.Drawing.Point(178, 161);
this.textBox_WebAppCode.Name = "textBox_WebAppCode";
this.textBox_WebAppCode.Size = new System.Drawing.Size(295, 20);
this.textBox_WebAppCode.TabIndex = 24;
//
// button_WebAppGetCode
//
this.button_WebAppGetCode.Location = new System.Drawing.Point(6, 159);
this.button_WebAppGetCode.Name = "button_WebAppGetCode";
this.button_WebAppGetCode.Size = new System.Drawing.Size(166, 23);
this.button_WebAppGetCode.TabIndex = 22;
this.button_WebAppGetCode.Text = "Acquire Authentication Code";
this.button_WebAppGetCode.UseVisualStyleBackColor = true;
this.button_WebAppGetCode.Click += new System.EventHandler(this.button_WebAppGetCode_Click);
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(138, 130);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(10, 13);
this.label6.TabIndex = 30;
this.label6.Text = " ";
//
// label2
//
@ -272,7 +323,7 @@
this.textBox_WebAppClientSecret.Location = new System.Drawing.Point(178, 107);
this.textBox_WebAppClientSecret.Name = "textBox_WebAppClientSecret";
this.textBox_WebAppClientSecret.Size = new System.Drawing.Size(295, 20);
this.textBox_WebAppClientSecret.TabIndex = 21;
this.textBox_WebAppClientSecret.TabIndex = 6;
this.textBox_WebAppClientSecret.Text = global::Office365APIEditor.Properties.Settings.Default.LastWebAppClientSecret;
//
// label10
@ -309,7 +360,7 @@
this.radioButton_WebAppExoResource.Location = new System.Drawing.Point(178, 84);
this.radioButton_WebAppExoResource.Name = "radioButton_WebAppExoResource";
this.radioButton_WebAppExoResource.Size = new System.Drawing.Size(106, 17);
this.radioButton_WebAppExoResource.TabIndex = 19;
this.radioButton_WebAppExoResource.TabIndex = 4;
this.radioButton_WebAppExoResource.TabStop = true;
this.radioButton_WebAppExoResource.Text = "Exchange Online";
this.radioButton_WebAppExoResource.UseVisualStyleBackColor = true;
@ -320,7 +371,7 @@
this.textBox_WebAppClientID.Location = new System.Drawing.Point(178, 32);
this.textBox_WebAppClientID.Name = "textBox_WebAppClientID";
this.textBox_WebAppClientID.Size = new System.Drawing.Size(295, 20);
this.textBox_WebAppClientID.TabIndex = 18;
this.textBox_WebAppClientID.TabIndex = 2;
this.textBox_WebAppClientID.Text = global::Office365APIEditor.Properties.Settings.Default.LastWebAppClientID;
//
// textBox_WebAppRedirectUri
@ -329,16 +380,16 @@
this.textBox_WebAppRedirectUri.Location = new System.Drawing.Point(178, 58);
this.textBox_WebAppRedirectUri.Name = "textBox_WebAppRedirectUri";
this.textBox_WebAppRedirectUri.Size = new System.Drawing.Size(295, 20);
this.textBox_WebAppRedirectUri.TabIndex = 17;
this.textBox_WebAppRedirectUri.TabIndex = 3;
this.textBox_WebAppRedirectUri.Text = global::Office365APIEditor.Properties.Settings.Default.LastWebAppRedirectURL;
//
// radioButton_NativeApp
//
this.radioButton_NativeApp.AutoSize = true;
this.radioButton_NativeApp.Location = new System.Drawing.Point(12, 297);
this.radioButton_NativeApp.Location = new System.Drawing.Point(12, 247);
this.radioButton_NativeApp.Name = "radioButton_NativeApp";
this.radioButton_NativeApp.Size = new System.Drawing.Size(110, 17);
this.radioButton_NativeApp.TabIndex = 27;
this.radioButton_NativeApp.TabIndex = 8;
this.radioButton_NativeApp.Text = "Native application";
this.radioButton_NativeApp.UseVisualStyleBackColor = true;
this.radioButton_NativeApp.CheckedChanged += new System.EventHandler(this.radioButton_NativeApp_CheckedChanged);
@ -350,7 +401,7 @@
this.radioButton_WebApp.Location = new System.Drawing.Point(12, 12);
this.radioButton_WebApp.Name = "radioButton_WebApp";
this.radioButton_WebApp.Size = new System.Drawing.Size(102, 17);
this.radioButton_WebApp.TabIndex = 28;
this.radioButton_WebApp.TabIndex = 1;
this.radioButton_WebApp.TabStop = true;
this.radioButton_WebApp.Text = "Web application";
this.radioButton_WebApp.UseVisualStyleBackColor = true;
@ -359,10 +410,10 @@
// radioButton_BasicAuth
//
this.radioButton_BasicAuth.AutoSize = true;
this.radioButton_BasicAuth.Location = new System.Drawing.Point(12, 529);
this.radioButton_BasicAuth.Location = new System.Drawing.Point(12, 479);
this.radioButton_BasicAuth.Name = "radioButton_BasicAuth";
this.radioButton_BasicAuth.Size = new System.Drawing.Size(225, 17);
this.radioButton_BasicAuth.TabIndex = 34;
this.radioButton_BasicAuth.TabIndex = 15;
this.radioButton_BasicAuth.Text = "Non application (Use basic authentication)";
this.radioButton_BasicAuth.UseVisualStyleBackColor = true;
this.radioButton_BasicAuth.CheckedChanged += new System.EventHandler(this.radioButton_BasicAuth_CheckedChanged);
@ -371,17 +422,28 @@
//
this.groupBox_BasicAuth.Controls.Add(this.button_BasicAuthGoNext);
this.groupBox_BasicAuth.Enabled = false;
this.groupBox_BasicAuth.Location = new System.Drawing.Point(26, 552);
this.groupBox_BasicAuth.Location = new System.Drawing.Point(26, 502);
this.groupBox_BasicAuth.Name = "groupBox_BasicAuth";
this.groupBox_BasicAuth.Size = new System.Drawing.Size(485, 51);
this.groupBox_BasicAuth.TabIndex = 35;
this.groupBox_BasicAuth.TabStop = false;
this.groupBox_BasicAuth.Text = "Basic authentication settings";
//
// button_BasicAuthGoNext
//
this.button_BasicAuthGoNext.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button_BasicAuthGoNext.Location = new System.Drawing.Point(9, 19);
this.button_BasicAuthGoNext.Name = "button_BasicAuthGoNext";
this.button_BasicAuthGoNext.Size = new System.Drawing.Size(98, 23);
this.button_BasicAuthGoNext.TabIndex = 16;
this.button_BasicAuthGoNext.Text = "Go to next page";
this.button_BasicAuthGoNext.UseVisualStyleBackColor = true;
this.button_BasicAuthGoNext.Click += new System.EventHandler(this.button_BasicAuthGoNext_Click);
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(32, 281);
this.label7.Location = new System.Drawing.Point(32, 231);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(10, 13);
this.label7.TabIndex = 30;
@ -390,113 +452,19 @@
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(50, 513);
this.label8.Location = new System.Drawing.Point(53, 463);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(10, 13);
this.label8.TabIndex = 30;
this.label8.Text = " ";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(6, 16);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(121, 13);
this.label9.TabIndex = 31;
this.label9.Text = "Step 1 : Fill out the form.";
//
// label15
//
this.label15.AutoSize = true;
this.label15.Location = new System.Drawing.Point(6, 143);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(185, 13);
this.label15.TabIndex = 31;
this.label15.Text = "Step 2 : Acquire Authentication Code.";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(138, 130);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(10, 13);
this.label6.TabIndex = 30;
this.label6.Text = " ";
//
// label16
//
this.label16.AutoSize = true;
this.label16.Location = new System.Drawing.Point(6, 197);
this.label16.Name = "label16";
this.label16.Size = new System.Drawing.Size(155, 13);
this.label16.TabIndex = 33;
this.label16.Text = "Step 3 : Acquire Access Token";
//
// label17
//
this.label17.AutoSize = true;
this.label17.Location = new System.Drawing.Point(181, 184);
this.label17.Name = "label17";
this.label17.Size = new System.Drawing.Size(10, 13);
this.label17.TabIndex = 32;
this.label17.Text = " ";
//
// button_WebAppAcquireAccessToken
//
this.button_WebAppAcquireAccessToken.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button_WebAppAcquireAccessToken.Location = new System.Drawing.Point(6, 213);
this.button_WebAppAcquireAccessToken.Name = "button_WebAppAcquireAccessToken";
this.button_WebAppAcquireAccessToken.Size = new System.Drawing.Size(130, 23);
this.button_WebAppAcquireAccessToken.TabIndex = 33;
this.button_WebAppAcquireAccessToken.Text = "Acquire Access Token";
this.button_WebAppAcquireAccessToken.UseVisualStyleBackColor = true;
this.button_WebAppAcquireAccessToken.Click += new System.EventHandler(this.button_WebAppAcquireAccessToken_Click);
//
// label18
//
this.label18.AutoSize = true;
this.label18.Location = new System.Drawing.Point(6, 16);
this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(121, 13);
this.label18.TabIndex = 34;
this.label18.Text = "Step 1 : Fill out the form.";
//
// label19
//
this.label19.AutoSize = true;
this.label19.Location = new System.Drawing.Point(6, 142);
this.label19.Name = "label19";
this.label19.Size = new System.Drawing.Size(155, 13);
this.label19.TabIndex = 34;
this.label19.Text = "Step 2 : Acquire Access Token";
//
// label20
//
this.label20.AutoSize = true;
this.label20.Location = new System.Drawing.Point(175, 130);
this.label20.Name = "label20";
this.label20.Size = new System.Drawing.Size(10, 13);
this.label20.TabIndex = 34;
this.label20.Text = " ";
//
// button_BasicAuthGoNext
//
this.button_BasicAuthGoNext.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button_BasicAuthGoNext.Location = new System.Drawing.Point(9, 19);
this.button_BasicAuthGoNext.Name = "button_BasicAuthGoNext";
this.button_BasicAuthGoNext.Size = new System.Drawing.Size(98, 23);
this.button_BasicAuthGoNext.TabIndex = 35;
this.button_BasicAuthGoNext.Text = "Go to next page";
this.button_BasicAuthGoNext.UseVisualStyleBackColor = true;
this.button_BasicAuthGoNext.Click += new System.EventHandler(this.button_BasicAuthGoNext_Click);
//
// StartForm
//
this.AcceptButton = this.button_NativeAppAcquireAccessToken;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.button_Cancel;
this.ClientSize = new System.Drawing.Size(521, 610);
this.ClientSize = new System.Drawing.Size(521, 586);
this.Controls.Add(this.groupBox_BasicAuth);
this.Controls.Add(this.radioButton_BasicAuth);
this.Controls.Add(this.button_Cancel);
@ -507,6 +475,7 @@
this.Controls.Add(this.radioButton_NativeApp);
this.Controls.Add(this.radioButton_WebApp);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "StartForm";
@ -536,8 +505,6 @@
private System.Windows.Forms.RadioButton radioButton_NativeAppExoResource;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.GroupBox groupBox_WebApp;
private System.Windows.Forms.TextBox textBox_WebAppCode;
private System.Windows.Forms.Button button_WebAppGetCode;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBox_WebAppClientSecret;
private System.Windows.Forms.Label label10;
@ -558,7 +525,6 @@
private System.Windows.Forms.Button button_WebAppAcquireAccessToken;
private System.Windows.Forms.Label label16;
private System.Windows.Forms.Label label17;
private System.Windows.Forms.Label label15;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Button button_BasicAuthGoNext;
private System.Windows.Forms.Label label7;

Просмотреть файл

@ -1,4 +1,7 @@
using Microsoft.IdentityModel.Clients.ActiveDirectory;
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using System;
using System.Collections;
using System.Text;
@ -11,8 +14,7 @@ namespace Office365APIEditor
{
public partial class StartForm : Form
{
// 戻り値用
// Return values
private TokenResponse _tokenResponse;
private string _resource = "";
@ -23,16 +25,15 @@ namespace Office365APIEditor
private void StartForm_Load(object sender, EventArgs e)
{
}
public enum ResourceTypes
{
radioButton_WebApp.Focus();
}
public DialogResult ShowDialog(out TokenResponse AccessToken, out string Resource, out string ClientID, out string ClientSecret)
{
DialogResult reult = this.ShowDialog();
// Build return values.
AccessToken = _tokenResponse;
Resource = _resource;
@ -46,6 +47,7 @@ namespace Office365APIEditor
ClientID = "";
ClientSecret = "";
}
return reult;
}
@ -70,7 +72,6 @@ namespace Office365APIEditor
groupBox_WebApp.Enabled = false;
}
private void button_NativeAppAcquireAccessToken_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.None;
@ -93,7 +94,7 @@ namespace Office365APIEditor
}
else
{
MessageBox.Show("Acquiring Access Token was failed.");
MessageBox.Show("Acquiring Access Token was failed.", "Office365APIEditor");
}
}
@ -106,13 +107,15 @@ namespace Office365APIEditor
{
return;
}
else if (textBox_WebAppCode.Text == "")
string authorizationCode = AcquireAuthorizationCode();
if (authorizationCode == "")
{
MessageBox.Show("Enter the Authorization Code.", "RESTAPIEditor");
return;
}
_tokenResponse = AcquireAccessTokenOfWebApp();
_tokenResponse = AcquireAccessTokenOfWebApp(authorizationCode);
if (_tokenResponse != null)
{
@ -123,7 +126,7 @@ namespace Office365APIEditor
}
else
{
MessageBox.Show("Acquiring Access Token was failed.");
MessageBox.Show("Acquiring Access Token was failed.", "Office365APIEditor");
}
}
@ -140,37 +143,7 @@ namespace Office365APIEditor
private void button_Cancel_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
Close();
}
private void button_WebAppGetCode_Click(object sender, EventArgs e)
{
if (CheckWebAppParam() == false)
{
return;
}
string Code = "";
_resource = GetResourceNameForWebApp();
GetCodeForm getCodeForm = new GetCodeForm(textBox_WebAppClientID.Text, textBox_WebAppRedirectUri.Text, GetResourceURL(_resource));
if (getCodeForm.ShowDialog(out Code) == DialogResult.OK)
{
if (Code == "")
{
MessageBox.Show("Getting Authorization Code was failed.", "RESTAPIEditor", MessageBoxButtons.OK, MessageBoxIcon.Error);
textBox_WebAppCode.Text = "";
}
else
{
textBox_WebAppCode.Text = Code;
}
}
else
{
MessageBox.Show("authentication_canceled: User canceled authentication", "RESTAPIEditor", MessageBoxButtons.OK, MessageBoxIcon.Error);
textBox_WebAppCode.Text = "";
}
this.Close();
}
private bool IsValidUrl(string Uri)
@ -188,25 +161,26 @@ namespace Office365APIEditor
private bool CheckWebAppParam()
{
// Web app の入力値のチェック
// Check the form for web app.
if (textBox_WebAppClientID.Text == "")
{
MessageBox.Show("Enter the Client ID.", "RESTAPIEditor");
MessageBox.Show("Enter the Client ID.", "Office365APIEditor");
return false;
}
else if (textBox_WebAppRedirectUri.Text == "")
{
MessageBox.Show("Enter the Redirect URL.", "RESTAPIEditor");
MessageBox.Show("Enter the Redirect URL.", "Office365APIEditor");
return false;
}
else if (!IsValidUrl(textBox_WebAppRedirectUri.Text))
{
MessageBox.Show("Format of Redirect URL is invalid.", "RESTAPIEditor");
MessageBox.Show("Format of Redirect URL is invalid.", "Office365APIEditor");
return false;
}
else if (textBox_WebAppClientSecret.Text == "")
{
MessageBox.Show("Enter the Client Secret.", "RESTAPIEditor");
MessageBox.Show("Enter the Client Secret.", "Office365APIEditor");
return false;
}
else
@ -217,35 +191,36 @@ namespace Office365APIEditor
private bool CheckNativeAppParam()
{
// Native app の入力値チェック
// Check the form for native app.
if (textBox_NativeAppTenantName.Text == "")
{
MessageBox.Show("Enter the Tenant Name.", "RESTAPIEditor");
MessageBox.Show("Enter the Tenant Name.", "Office365APIEditor");
return false;
}
else if (!textBox_NativeAppTenantName.Text.EndsWith(".onmicrosoft.com"))
{
MessageBox.Show("Format of Tenant Name is invalid.\ne.g. contoso.onmicrosoft.com", "RESTAPIEditor");
MessageBox.Show("Format of Tenant Name is invalid.\ne.g. contoso.onmicrosoft.com", "Office365APIEditor");
return false;
}
else if (!IsValidUrl("https://login.windows.net/" + textBox_NativeAppTenantName.Text))
{
MessageBox.Show("Format of Tenant Name is invalid.\ne.g. contoso.onmicrosoft.com", "RESTAPIEditor");
MessageBox.Show("Format of Tenant Name is invalid.\ne.g. contoso.onmicrosoft.com", "Office365APIEditor");
return false;
}
else if (textBox_NativeAppClientID.Text == "")
{
MessageBox.Show("Enter the Client ID.", "RESTAPIEditor");
MessageBox.Show("Enter the Client ID.", "Office365APIEditor");
return false;
}
else if (textBox_NativeAppRedirectUri.Text == "")
{
MessageBox.Show("Enter the Redirect URL.", "RESTAPIEditor");
MessageBox.Show("Enter the Redirect URL.", "Office365APIEditor");
return false;
}
else if (!IsValidUrl(textBox_NativeAppRedirectUri.Text))
{
MessageBox.Show("Format of Redirect URL is invalid.", "RESTAPIEditor");
MessageBox.Show("Format of Redirect URL is invalid.", "Office365APIEditor");
return false;
}
else
@ -254,65 +229,76 @@ namespace Office365APIEditor
}
}
private TokenResponse AcquireAccessTokenOfWebApp()
private string AcquireAuthorizationCode()
{
string Code = "";
_resource = GetResourceNameForWebApp();
GetCodeForm getCodeForm = new GetCodeForm(textBox_WebAppClientID.Text, textBox_WebAppRedirectUri.Text, GetResourceURL(_resource));
if (getCodeForm.ShowDialog(out Code) == DialogResult.OK)
{
if (Code == "")
{
MessageBox.Show("Getting Authorization Code was failed.", "Office365APIEditor", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("authentication_canceled: User canceled authentication", "Office365APIEditor", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
return Code;
}
private TokenResponse AcquireAccessTokenOfWebApp(string AuthorizationCode)
{
TokenResponse result = null;
string accessToken = "";
//文字コードを指定する
System.Text.Encoding enc = System.Text.Encoding.Default;
// Build a POST body.
string postBody = "";
Hashtable tempTable = new Hashtable();
//POST送信する文字列を作成
string param = "";
Hashtable ht = new Hashtable();
tempTable["grant_type"] = "authorization_code";
tempTable["code"] = AuthorizationCode;
tempTable["redirect_uri"] = textBox_WebAppRedirectUri.Text;
tempTable["client_id"] = textBox_WebAppClientID.Text;
tempTable["client_secret"] = textBox_WebAppClientSecret.Text;
ht["grant_type"] = "authorization_code";
ht["code"] = textBox_WebAppCode.Text;
ht["redirect_uri"] = textBox_WebAppRedirectUri.Text;
ht["client_id"] = textBox_WebAppClientID.Text;
ht["client_secret"] = textBox_WebAppClientSecret.Text;
foreach (string k in ht.Keys)
foreach (string key in tempTable.Keys)
{
param += String.Format("{0}={1}&", k, ht[k]);
postBody += String.Format("{0}={1}&", key, tempTable[key]);
}
byte[] postDataBytes = Encoding.ASCII.GetBytes(param);
byte[] postDataBytes = Encoding.ASCII.GetBytes(postBody);
//WebRequestの作成
System.Net.WebRequest req = System.Net.WebRequest.Create("https://login.windows.net/common/oauth2/token/");
//メソッドにPOSTを指定
req.Method = "POST";
//ContentTypeを"application/x-www-form-urlencoded"にする
req.ContentType = "application/x-www-form-urlencoded";
//POST送信するデータの長さを指定
req.ContentLength = postDataBytes.Length;
System.Net.WebRequest request = System.Net.WebRequest.Create("https://login.windows.net/common/oauth2/token/");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = postDataBytes.Length;
try
{
//データをPOST送信するためのStreamを取得
using (System.IO.Stream reqStream = req.GetRequestStream())
// Get a RequestStream to POST a data.
using (Stream reqestStream = request.GetRequestStream())
{
//送信するデータを書き込む
reqStream.Write(postDataBytes, 0, postDataBytes.Length);
reqestStream.Write(postDataBytes, 0, postDataBytes.Length);
}
//サーバーからの応答を受信するためのWebResponseを取得
System.Net.WebResponse res = req.GetResponse();
//応答データを受信するためのStreamを取得
using (System.IO.Stream resStream = res.GetResponseStream())
System.Net.WebResponse response = request.GetResponse();
using (Stream responseStream = response.GetResponseStream())
{
//受信して表示
System.IO.StreamReader sr = new System.IO.StreamReader(resStream, enc);
string response = sr.ReadToEnd();
StreamReader reader = new StreamReader(responseStream, Encoding.Default);
string jsonResponse = reader.ReadToEnd();
// デシリアライズして Access Token を取得
result = Deserialize<TokenResponse>(response);
// Deserialize and get an Access Token.
result = Deserialize<TokenResponse>(jsonResponse);
accessToken = result.access_token;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "\r\n\r\n" + ex.StackTrace);
MessageBox.Show(ex.Message + "\r\n\r\n" + ex.StackTrace, "Office365APIEditor");
}
return result;
@ -332,10 +318,10 @@ namespace Office365APIEditor
string errorMessage = null;
try
{
// Office365 のサインインページを表示する
// Show a Sign-in page of Office365.
authenticationResult = authenticationContext.AcquireToken(resourceName, clientId, redirectUri, PromptBehavior.Always);
// 資格情報をハードコードする場合
// If we use hardcoded user credential, use this method.
// authenticationResult = authenticationContext.AcquireToken(resourceName, clientId, new UserCredential("SMTP Address", "password"));
}
catch (AdalException ex)
@ -353,7 +339,7 @@ namespace Office365APIEditor
if (!string.IsNullOrEmpty(errorMessage))
{
MessageBox.Show(errorMessage, "RESTAPIEditor", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show(errorMessage, "Office365APIEditor", MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}
else
@ -410,20 +396,23 @@ namespace Office365APIEditor
public static T Deserialize<T>(string json)
{
T returnValue;
T result;
using (var memoryStream = new MemoryStream())
{
byte[] jsonBytes = Encoding.UTF8.GetBytes(json);
memoryStream.Write(jsonBytes, 0, jsonBytes.Length);
byte[] jsonByteArray = Encoding.UTF8.GetBytes(json);
memoryStream.Write(jsonByteArray, 0, jsonByteArray.Length);
memoryStream.Seek(0, SeekOrigin.Begin);
using (var jsonReader = JsonReaderWriterFactory.CreateJsonReader(memoryStream, Encoding.UTF8, XmlDictionaryReaderQuotas.Max, null))
{
var serializer = new DataContractJsonSerializer(typeof(T));
returnValue = (T)serializer.ReadObject(jsonReader);
result = (T)serializer.ReadObject(jsonReader);
}
}
return returnValue;
return result;
}
public static TokenResponse ConvertAuthenticationResultToTokenResponse(AuthenticationResult value)

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,4 +1,7 @@
using System;
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичные данные
Office365APIEditor/image.ico Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 279 KiB

Просмотреть файл

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2016 Microsoft
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Двоичный файл не отображается.

Просмотреть файл

@ -1,2 +1,30 @@
# Office365APIEditor
You can test Office 365 API easily.
## Download options
Download Office365APIEditor from [releases](https://github.com/Microsoft/Office365APIEditor/releases) page.
## Features
You can test Office 365 API. We support following endpoints.
- outlook.office.com and outlook.office365.com (Exchange Online)
- graph.microsoft.com (Microsoft Graph)
You can use OAuth or Basic authentication as authentication mechanisms.
## Prerequisites
You need the following to work with Office365APIEditor:
- Subscription of Office 365 and a user account.
- Version of the .NET Framework starting with the .NET Framework 4.5.
And you need the following to use OAuth.
- Subscriotion of Microsoft Azure which manages Azure Active Directory of your Office 365 tennant.
- Application which was registered in Azure Active Directory.
## Feedback
If you have any feedback, please post to the [Issues](https://github.com/Microsoft/Office365APIEditor/issues) list.