Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
v0.9.3.0
Browse files Browse the repository at this point in the history
Applied to the new Azure portal.
Add support of App-Only Tokne which uses Client Secret.
  • Loading branch information
rykoma committed Jun 4, 2017
1 parent c4037ba commit 14e78e2
Show file tree
Hide file tree
Showing 13 changed files with 917 additions and 330 deletions.
734 changes: 504 additions & 230 deletions Office365APIEditor/AccessTokenWizard.Designer.cs

Large diffs are not rendered by default.

244 changes: 196 additions & 48 deletions Office365APIEditor/AccessTokenWizard.cs

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions Office365APIEditor/AcquireViewerTokenForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Office365APIEditor/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@
<setting name="AllowAutoRedirect" serializeAs="String">
<value>False</value>
</setting>
<setting name="LastWebAppAppOnlyByKeyTenantName" serializeAs="String">
<value />
</setting>
<setting name="LastWebAppAppOnlyByKeyClientID" serializeAs="String">
<value />
</setting>
<setting name="LastWebAppAppOnlyByKeyClientSecret" serializeAs="String">
<value />
</setting>
</Office365APIEditor.Properties.Settings>
</userSettings>
<applicationSettings>
Expand Down
66 changes: 62 additions & 4 deletions Office365APIEditor/GetCodeForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,56 @@ public partial class GetCodeForm : Form
private string _acquiredCode = "";

public GetCodeForm(string ClientID, string RedirectUri, string ResourceOrScopeUri, bool IsV2 = false, string TenantName = "")
{
InternalInitialization(ClientID, RedirectUri, ResourceOrScopeUri, IsV2, TenantName, false);

//InitializeComponent();

//redirectUrl = RedirectUri;

//// Build an URL of sign-in page.

//string endPoint = "https://login.microsoftonline.com/";

//if (TenantName == "")
//{
// endPoint += "common/oauth2";
//}
//else
//{
// endPoint += TenantName.Replace("@", ".") + "/oauth2";
//}

//if (IsV2 == true)
//{
// endPoint += "/v2.0";
// authenticationUrl = endPoint + "/authorize?" +
// "response_type=code" +
// "&client_id=" + ClientID +
// "&redirect_uri=" + System.Web.HttpUtility.UrlEncode(RedirectUri) +
// "&scope=" + System.Web.HttpUtility.UrlEncode(ResourceOrScopeUri) +
// "&response_mode=query" +
// "&prompt=login";
//}
//else
//{
// authenticationUrl = endPoint + "/authorize?" +
// "resource=" + System.Web.HttpUtility.UrlEncode(ResourceOrScopeUri) +
// "&response_type=code" +
// "&redirect_uri=" + System.Web.HttpUtility.UrlEncode(RedirectUri) +
// "&client_id=" + ClientID +
// "&prompt=login";
//}

//webBrowser1.DocumentTitleChanged += new EventHandler(webBrowser1_DocumentTitleChanged);
}

public GetCodeForm(string ClientID, string RedirectUri, string ResourceOrScopeUri, bool IsV2, bool AdminConsent)
{
InternalInitialization(ClientID, RedirectUri, ResourceOrScopeUri, IsV2, "", AdminConsent);
}

private void InternalInitialization(string ClientID, string RedirectUri, string ResourceOrScopeUri, bool IsV2 = false, string TenantName = "", bool AdminConsent = false)
{
InitializeComponent();

Expand All @@ -42,17 +92,25 @@ public GetCodeForm(string ClientID, string RedirectUri, string ResourceOrScopeUr
"&client_id=" + ClientID +
"&redirect_uri=" + System.Web.HttpUtility.UrlEncode(RedirectUri) +
"&scope=" + System.Web.HttpUtility.UrlEncode(ResourceOrScopeUri) +
"&response_mode=query" +
"&prompt=login";
"&response_mode=query";
}
else
{
authenticationUrl = endPoint + "/authorize?" +
"resource=" + System.Web.HttpUtility.UrlEncode(ResourceOrScopeUri) +
"&response_type=code" +
"&redirect_uri=" + System.Web.HttpUtility.UrlEncode(RedirectUri) +
"&client_id=" + ClientID +
"&prompt=login";
"&client_id=" + ClientID;

if (AdminConsent)
{
authenticationUrl += "&prompt=admin_consent";
}
else
{
authenticationUrl += "&prompt=login";
}

}

webBrowser1.DocumentTitleChanged += new EventHandler(webBrowser1_DocumentTitleChanged);
Expand Down
10 changes: 9 additions & 1 deletion Office365APIEditor/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,15 @@ static void Main(string[] args)
}
catch (Exception ex)
{
MessageBox.Show(ex.InnerException.Message);
if (ex.InnerException == null)
{
MessageBox.Show(ex.Message, "Office365APIEditor", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
MessageBox.Show(ex.InnerException.Message, "Office365APIEditor", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}

}
}

Expand Down
4 changes: 2 additions & 2 deletions Office365APIEditor/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// 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.9.2.3")]
[assembly: AssemblyFileVersion("0.9.2.3")]
[assembly: AssemblyVersion("0.9.3.0")]
[assembly: AssemblyFileVersion("0.9.3.0")]
36 changes: 36 additions & 0 deletions Office365APIEditor/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Office365APIEditor/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,14 @@
<Setting Name="AllowAutoRedirect" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="LastWebAppAppOnlyByKeyTenantName" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="LastWebAppAppOnlyByKeyClientID" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="LastWebAppAppOnlyByKeyClientSecret" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>
32 changes: 15 additions & 17 deletions tutorials/How_to_register_a_V1_Native_application.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,31 @@
This tutorial introduces how to register the application using Microsoft Azure portal.
Once you registered an application by following this tutorial, you can use it as a "Native application" in Office365APIEditor.

1. Go to https://manage.windowsazure.com/ and sign in using your administrator account of Microsoft Azure.
1. Go to https://portal.azure.com/ and sign in using your administrator account of Microsoft Azure.

2. Click [Active Directory] in the left panel.
2. Click [Azure Active Directory] in the left panel.

3. In [DIRECTORY] tab, select the name of your organization.
3. Click [App registration] tab.

4. In [APPLICATIONS] tab, click [ADD] at the bottom.
4. Click [New application registration].

5. Click [Add an application my organization is developing].
5. Enter the name of your application. (e.g. MyNativeApp)

6. Enter the name of your application. (e.g. MyNativeApp)
6. Select [Native].

7. Select [NATIVE CLIENT APPLICATION] and go to the next page.
7. Enter the Redirect URI of your application in [Redirect URI] box. (e.g. https&#58;<span></span>//localhost/MyNativeApp <- Whatever is fine.)

8. Enter the redirect URI of your application in [REDIRECT URI] box. (e.g. http://localhost/MyNativeApp <- Whatever is fine.)
8. Click [Create].

9. Click [Complete].
9. Click the application which you created.

10. In [CONFIGURE] tab, Go to [permissions to other applications] section and add the necessary permissions for your application.
If your application has to read the messages in users mailbox using Office 365 API (outlook.office.com), you have to add the [Read user mail] permission under [Delegated Permissions] of [Office 365 Exchange Online].
If your application has to read the messages in users mailbox using Graph API (graph.microsoft.com), you have to add the [Read user mail] permission under [Delegated Permissions] of [Microsoft Graph].
10. Click [Required permissions] and add the necessary permissions for your application.
If your application has to read the messages in users mailbox using Office 365 API (outlook.office.com), you have to add the [Read user mail] permission under [DELEGATED PERMISSIONS] of [Office 365 Exchange Online (Microsoft.Exchange)].
If your application has to read the messages in users mailbox using Graph API (graph.microsoft.com), you have to add the [Read user mail] permission under [DELEGATED PERMISSIONS] of [Microsoft Graph].

11. Click [SAVE] at the bottom.

13. Check the following values and use them in Office365APIEditor.
11. Check the following values and use them in Office365APIEditor.

| Value in Azure portal | Textbox in Office365APIEditor |
|:----------------------|-------------------------------|
|CLIENT ID |Client ID |
|REDIRECT URI |Redirect URL |
|Application ID |Application ID |
|Redirect URI |Redirect URI |
44 changes: 24 additions & 20 deletions tutorials/How_to_register_a_V1_Web_application.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,44 @@
# How to register a V1 Web application

This tutorial introduces how to register the application using Microsoft Azure portal.
Once you registered an application by following this tutorial, you can use it as a "Web application" in Office365APIEditor.
Once you registered an application by following this tutorial, you can use it as a "Web app / API" in Office365APIEditor.

1. Go to https://manage.windowsazure.com/ and sign in using your administrator account of Microsoft Azure.
1. Go to https://portal.azure.com/ and sign in using your administrator account of Microsoft Azure.

2. Click [Active Directory] in the left panel.
2. Click [Azure Active Directory] in the left panel.

3. In [DIRECTORY] tab, select the name of your organization.
3. Click [App registration] tab.

4. In [APPLICATIONS] tab, click [ADD] at the bottom.
4. Click [New application registration].

5. Click [Add an application my organization is developing].
5. Enter the name of your application. (e.g. MyWebApp)

6. Enter the name of your application. (e.g. MyWebApp)
6. Select [Web app / API].

7. Select [WEB APPLICATION AND/OR WEB API] and go to the next page.
7. Enter the sing-on URL of your application in [Sign-on URL] box. (e.g. https&#58;<span></span>//localhost/MyWebApp <- Whatever is fine.)

8. Enter the sing-in URL of your application in [SIGN-ON URL] box. (e.g. http&#58;<span></span>//localhost/MyWebApp <- Whatever is fine.)
8. Click [Create].

9. Enter the APP ID URI of your application in [APP ID URI] box (e.g. http&#58;<span></span>//contoso.onmicrosoft.com/MyWebApp <- Whatever is fine.)
9. Click the application which you created.

10. Click [Complete].
10. Click [Keys].

11. In [CONFIGURE] tab, go to [Keys] section and select the duration of the key. (e.g. 2 years)
11. Enter the name of your key. (e.g. Key01)

12. Go to [permissions to other applications] section and add the necessary permissions for your application.
If your application has to read the messages in users mailbox using Office 365 API (outlook.office.com), you have to add the [Read user mail] permission under [Delegated Permissions] of [Office 365 Exchange Online].
If your application has to read the messages in users mailbox using Graph API (graph.microsoft.com), you have to add the [Read user mail] permission under [Delegated Permissions] of [Microsoft Graph].
12. Select the duration of the key. (e.g. 2 years)

13. Click [SAVE] at the bottom.
13. Click [Save].

14. Check the following values and use them in Office365APIEditor.
14. Copy the [Value] to the safety place.

15. Click [Required permissions] and add the necessary permissions for your application.
If your application has to read the messages in users mailbox using Office 365 API (outlook.office.com), you have to add the [Read user mail] permission under [DELEGATED PERMISSIONS] of [Office 365 Exchange Online (Microsoft.Exchange)].
If your application has to read the messages in users mailbox using Graph API (graph.microsoft.com), you have to add the [Read user mail] permission under [DELEGATED PERMISSIONS] of [Microsoft Graph].

16. Check the following values and use them in Office365APIEditor.

| Value in Azure portal | Textbox in Office365APIEditor |
|:----------------------|-------------------------------|
|SIGN-ON URL |Redirect URL |
|CLIENT ID |Client ID |
|key in [Keys] section |Client Secret |
|Application ID |Application ID |
|Reply URL |Reply URL |
|Value of Key |Key |
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# How to register a V1 Web application for App Only Token

This tutorial introduces how to register the application using Microsoft Azure portal.
Once you registered an application by following this tutorial, you can use it as a "Web application (Use App Only Token)" in Office365APIEditor.
Once you registered an application by following this tutorial, you can use it as a "Web app / API (Use App Only Token by certificate)" in Office365APIEditor.

1. Go to https://manage.windowsazure.com/ and sign in using your administrator account of Microsoft Azure.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# How to register a V1 Web application for App Only Token which uses the Key to acquire the Access Token

This tutorial introduces how to register the application using Microsoft Azure portal.
Once you registered an application by following this tutorial, you can use it as a "Web app / API (Use App Only Token by key)" in Office365APIEditor.

1. Go to https://portal.azure.com/ and sign in using your administrator account of Microsoft Azure.

2. Click [Azure Active Directory] in the left panel.

3. Click [App registration] tab.

4. Click [New application registration].

5. Enter the name of your application. (e.g. MyAppOnlyTokenApp)

6. Select [Web app / API].

7. Enter the sing-on URL of your application in [Sign-on URL] box. (e.g. https&#58;<span></span>//localhost/MyAppOnlyTokenApp <- Whatever is fine.)

8. Click [Create].

9. Click the application which you created.

10. Click [Keys].

11. Enter the name of your key. (e.g. Key01)

12. Select the duration of the key. (e.g. 2 years)

13. Click [Save].

14. Copy the [Value] to the safety place.

15. Click [Required permissions] and add the necessary permissions for your application.
If your application has to read the message in all mailboxes of all users using Graph API (graph.microsoft.com), you have to add the [Read mail in all mailboxes] permission under [APPLICATION PERMISSIONS] of [Microsoft Graph].

16. Check the following values and use them in Office365APIEditor.
If you have not completed ADMIN CONSENT, complete it before acquiring Access Token.

| Value in Azure portal | Textbox in Office365APIEditor |
|:----------------------|-------------------------------|
|Application ID |Application ID |
|Value of Key |Key |

0 comments on commit 14e78e2

Please sign in to comment.