# Create an Azure App

## Create a New OAuth Application

1. Create a Microsoft Azure account, if you don't already have one. <https://azure.microsoft.com/en-us/free/>
2. Login to the Microsoft Azure portal here <https://portal.azure.com/>
3. If you don't already have an active subscription or your account is new, start a new subscription by clicking the **Start** button under ***Start with an Azure free trial.*** Without an active subscription, you won't have access to the resources needed to create your Azure App.

<figure><img src="https://703485338-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzAOD4a5iAUra2DB1y99h%2Fuploads%2FMIAQBNlryfT6IX2sDMlI%2Fazure-start-free-trial.PNG?alt=media&#x26;token=9049c806-f413-4e62-86fa-e8aa1a0a3d32" alt=""><figcaption></figcaption></figure>

4. From the left menu, click on **Azure Active Directory.**&#x20;

   *<mark style="color:orange;">\*\*Note:</mark>* **Azure Active Directory** is now called **Microsoft Entra ID**

<figure><img src="https://703485338-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzAOD4a5iAUra2DB1y99h%2Fuploads%2FCdcbWf3X3bRnDc0GsYLn%2Fazure-active-directory.PNG?alt=media&#x26;token=bb8b40ae-5152-48a8-9538-a4cae39ecf7a" alt=""><figcaption></figcaption></figure>

5. From the Active Directory menu, click on **App Registrations** and then click on **New Registration**

<figure><img src="https://703485338-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzAOD4a5iAUra2DB1y99h%2Fuploads%2FpXTmGrRUwQErfaHx0VsR%2Fazure-app-registrations.PNG?alt=media&#x26;token=7f629c65-6364-4cc2-8ef8-586a6e23b5dd" alt=""><figcaption></figcaption></figure>

### **New App Registration**

1. Add a name for your application
2. Choose the account types you want to support. If you're not sure which type to choose, click on the <mark style="color:blue;">Help me choose...</mark> link.
3. For Redirect URI, select **Web** and add the following URI: `https://api.pyas.io/oauth/microsoft/callback` .   We'll add more redirect URIs later.
4. Click on Register

<figure><img src="https://703485338-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzAOD4a5iAUra2DB1y99h%2Fuploads%2FD4EaawAQ6kgPUI5txtaB%2Fazure-register-app.PNG?alt=media&#x26;token=bdb0d295-1083-4e9c-b73e-2a4f6f7edcaa" alt=""><figcaption></figcaption></figure>

You've now registered your new Azure App. But, we need to configure some things.

### Enable APIs for Your App

1. From the App Registrations page, select your app.

<figure><img src="https://703485338-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzAOD4a5iAUra2DB1y99h%2Fuploads%2Fc2mlFHMRldlaB8lPjDl6%2Fazure-select-app.PNG?alt=media&#x26;token=14327d66-ce41-4455-960c-4e1d03dfe99d" alt=""><figcaption></figcaption></figure>

2. Click on **API Permissions** on the left menu and then click on **Add a permission**.

<figure><img src="https://703485338-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzAOD4a5iAUra2DB1y99h%2Fuploads%2FW1AVW6UKLNGDHMK6nDgt%2Fazure-add-permissions.PNG?alt=media&#x26;token=6d377f3e-06e1-4e72-a4f2-dcc6cc0d05c4" alt=""><figcaption></figcaption></figure>

3. Click on **Microsoft Graph** then click on **Delegated Permissions.**

<figure><img src="https://703485338-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzAOD4a5iAUra2DB1y99h%2Fuploads%2FrUm2fIdv811ijzyPQNGE%2Fmicrosoft-graph.PNG?alt=media&#x26;token=e3537359-13b8-4200-bdd8-071c14f71e1d" alt=""><figcaption></figcaption></figure>

<figure><img src="https://703485338-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzAOD4a5iAUra2DB1y99h%2Fuploads%2F8BrIZZzpA9vptBiB8H9b%2Fazure-delegated-permissions.PNG?alt=media&#x26;token=c227cd97-fcbd-4bec-a678-1d82706294ee" alt=""><figcaption></figcaption></figure>

4. Search for and select to following API permissions

   * openid
   * profile
   * offline\_access
   * User.Read
   * email
   * Calendars.Read
   * Calendars.ReadBasic
   * Calendars.Read.Shared
   * Calendars.ReadWrite
   * Calendars.ReadWrite.Shared
   * Subscription.Read.All
   * OnlineMeetings.Read - *<mark style="color:blue;">Optional. Select this scope if you plan on adding Microsoft Teams conferencing to events</mark>*
   * OnlineMeetings.ReadWrite - *<mark style="color:blue;">Optional. Select this scope if you plan on adding Microsoft Teams conferencing to events</mark>*

5. Click the **Add Permissions** button.

<figure><img src="https://703485338-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzAOD4a5iAUra2DB1y99h%2Fuploads%2F2eXlIscilAaq0okRyUTB%2Fcalendars-permissions.PNG?alt=media&#x26;token=b6984d35-2051-452b-9719-7719e2926296" alt=""><figcaption></figcaption></figure>

<figure><img src="https://703485338-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzAOD4a5iAUra2DB1y99h%2Fuploads%2FMJm9T9oqebWcugYCz5PD%2Fms-api-permissions.PNG?alt=media&#x26;token=bd06c804-0071-41f1-942e-9bdaeb190d4b" alt=""><figcaption></figcaption></figure>

### Update App Branding

1. From your app page, click on **Branding & Properties** in the left menu.
2. Fill out the form fields for branding (App Name, Logo, Home Page Url, etc..)
3. Click **save.**

<figure><img src="https://703485338-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzAOD4a5iAUra2DB1y99h%2Fuploads%2FCWm3j9fuYq9xi2Asdp0Q%2Fms-app-branding.PNG?alt=media&#x26;token=c9a9ad6e-217d-449b-b28c-d6a6a5b1fd8c" alt=""><figcaption></figcaption></figure>

### Add More Redirect URIs

1. From your app page, click on **Authentication** in the left menu.
2. Click the **Web** dropdown
3. Click **Add URI**
4. Add `https://www.app.pyas.io/org/apps/oauth/microsoft/callback` as a redirect URI.
5. Add your own redirect URIs as needed
6. Click **Save**

<figure><img src="https://703485338-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzAOD4a5iAUra2DB1y99h%2Fuploads%2FMge5QH9Z5KzYOcEueFUs%2Fms-redirect.PNG?alt=media&#x26;token=6056d161-9f16-4e8f-8b45-6f59bcab8f0a" alt=""><figcaption></figcaption></figure>

###

### Create OAuth Credentials

1. From your app page, select **Certificates & Secrets** on the left menu
2. Click on **New Client Secret.**
3. Add a description for your secret and select **24 months** as the expiration date.
4. Click **Add**.

<figure><img src="https://703485338-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzAOD4a5iAUra2DB1y99h%2Fuploads%2FNkhiJo7tz7pQi1UryCHp%2Fms-secret.PNG?alt=media&#x26;token=b5d58b46-ff49-4993-8177-350736a43688" alt=""><figcaption></figcaption></figure>

5. Copy the secret value

<figure><img src="https://703485338-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzAOD4a5iAUra2DB1y99h%2Fuploads%2FIOk9oSfMHfqbj2KwebFr%2Fms-secret-value.PNG?alt=media&#x26;token=92c623ad-78b2-45ca-a2f2-814e4b945a1c" alt=""><figcaption></figcaption></figure>

### Add Your Azure App's OAuth Client ID and Client Secret to Pyas

1. Login to your Pyas account
2. Select the Pyas App you will be updating
3. Go to the Pyas App's settings tab
4. Click on Authentication
5. Under **Pyas Authentication**, toggle the **Enable Pyas Auth for Microsoft Accounts** switch off. Then, click the **Save Pyas Auth Settings** button.

<figure><img src="https://703485338-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzAOD4a5iAUra2DB1y99h%2Fuploads%2Fzkb3uhMKrDrC5JClqXwZ%2Fms-pyas-1.PNG?alt=media&#x26;token=6c530375-6e2a-4466-8e05-4f4715d7e970" alt=""><figcaption></figcaption></figure>

6. Scroll down to the **Native Microsoft Authentication** section
7. Paste the client secret value you copied earlier into the **Microsoft Oauth Client Secret** field

<figure><img src="https://703485338-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzAOD4a5iAUra2DB1y99h%2Fuploads%2Fem4PnAnOibWstx5JuL1x%2Fms-secret-2.PNG?alt=media&#x26;token=f8e0545a-2e5f-4dad-b2ef-65ccf25a24fd" alt=""><figcaption></figcaption></figure>

8. From your Azure portal, click on **App Registrations**
9. Copy the Application ID of your Azure App

<figure><img src="https://703485338-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzAOD4a5iAUra2DB1y99h%2Fuploads%2FjLiAza90YEUo8HT9i9e1%2Fms-client-id.PNG?alt=media&#x26;token=b0a86cb3-c4a7-4626-b341-f2a28c59818b" alt=""><figcaption></figcaption></figure>

10. Go back to the **Native Microsoft Authentication** section of your Pyas App's Authentication settings
11. Paste your Azure App's Client ID into the **Microsoft Oauth Client ID** field.
12. Add your Azure App's redirect URL into the **Microsoft Callback URL** field.&#x20;
13. Click **Save Microsoft Settings**

<figure><img src="https://703485338-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzAOD4a5iAUra2DB1y99h%2Fuploads%2FKq8AMqUj1A92EeGiA9bu%2Fms-oauth.PNG?alt=media&#x26;token=073c5531-88ba-4319-bfda-6618997875af" alt=""><figcaption></figcaption></figure>

**That's it!** You should now be able to use your Azure App with Pyas to add Outlook Calendar integrations into your app.

Note: Microsoft requires apps that access user data to go through a [domain verification process](https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-configure-publisher-domain), when you're ready to take your app to production.
