Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync with latest SDKs, and refresh of documentation. #113

Merged
merged 1 commit into from
Aug 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<PackageReference Include="Microsoft.AspNetCore.Mvc.WebApiCompatShim" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.1.1" />
<PackageReference Include="Microsoft.Graph.Communications.Calls" Version="1.1.0-prerelease.581" />
<PackageReference Include="Microsoft.Graph.Communications.Calls" Version="1.1.0-prerelease.1511" />
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="4.9.0" />
<ProjectReference Include="..\..\..\Common\Sample.Common\Sample.Common.csproj" />
<Reference Include="System.Net.Http" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
namespace Sample.OnlineMeeting
{
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Graph;
using Microsoft.Graph.Communications.Client.Authentication;
using Microsoft.Graph.Communications.Core;
using Microsoft.Graph.Communications.Common;

/// <summary>
/// Online meeting class to fetch meeting info based of meeting id (ex: vtckey).
Expand All @@ -35,19 +36,21 @@ public OnlineMeeting(IRequestAuthenticationProvider requestAuthenticationProvide
/// Permissions required : Either OnlineMeetings.Read.All or OnlineMeetings.ReadWrite.All.
/// </summary>
/// <param name="tenantId">The tenant identifier.</param>
/// <param name="meetingId">The meeting identifier.</param>
/// <param name="vtcId">The vtcid assoiciated with the meeting.</param>
/// <param name="scenarioId">The scenario identifier - needed in case of debugging for correlating client side request with server side logs.</param>
/// <returns> The onlinemeeting. </returns>
public async Task<Microsoft.Graph.OnlineMeeting> GetOnlineMeetingAsync(string tenantId, string meetingId, Guid scenarioId)
public async Task<Microsoft.Graph.OnlineMeeting> GetOnlineMeetingByVtcIdAsync(string tenantId, string vtcId, Guid scenarioId)
{
var statelessClient = new CallsGraphServiceClient(
this.graphEndpointUri.AbsoluteUri,
this.GetAuthenticationProvider(tenantId, scenarioId));

var meetingRequest = statelessClient.App.OnlineMeetings[meetingId].Request();
var meeting = await meetingRequest.GetAsync().ConfigureAwait(false);
var meetingRequestCollection = statelessClient.App.OnlineMeetings.Request();
meetingRequestCollection.Filter($"VideoTeleconferenceId eq '{vtcId}'");

return meeting;
var meeting = await meetingRequestCollection.GetAsync().ConfigureAwait(false);

return meeting.First();
}

/// <summary>
Expand Down Expand Up @@ -100,8 +103,8 @@ private IAuthenticationProvider GetAuthenticationProvider(string tenantId, Guid
{
return new DelegateAuthenticationProvider(async request =>
{
request.Headers.Add(CommsConstants.Headers.ScenarioId, scenarioId.ToString());
request.Headers.Add(CommsConstants.Headers.ClientRequestId, Guid.NewGuid().ToString());
request.Headers.Add(HttpConstants.HeaderNames.ScenarioId, scenarioId.ToString());
request.Headers.Add(HttpConstants.HeaderNames.ClientRequestId, Guid.NewGuid().ToString());

await this.requestAuthenticationProvider.AuthenticateOutboundRequestAsync(request, tenantId)
.ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<Import Project="$(MSBuildThisFileDirectory)..\..\..\Graph.props" />

<ItemGroup>
<PackageReference Include="Microsoft.Graph.Communications.Client" Version="1.1.0-prerelease.581" />
<PackageReference Include="Microsoft.Graph.Communications.Core.Calls" Version="1.1.0-prerelease.581" />
<PackageReference Include="Microsoft.Graph.Communications.Client" Version="1.1.0-prerelease.1511" />
<PackageReference Include="Microsoft.Graph.Communications.Core.Calls" Version="1.1.0-prerelease.1511" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Program
private static string appSecret = "__placeholder__";
private static string appId = "__placeholder__";

private static string meetingId = "__placeholder__";
private static string vtcId = "__placeholder__";
private static string tenantId = "__placeholder__";
private static string organizerID = "__placeholder__";

Expand All @@ -28,17 +28,17 @@ public class Program
/// Gets the online meeting asynchronous.
/// </summary>
/// <param name="tenantId">The tenant identifier.</param>
/// <param name="meetingId">The meeting identifier.</param>
/// <param name="videoTeleconferenceId">The meeting identifier.</param>
/// <returns> The onlinemeeting details. </returns>
public static async Task<Microsoft.Graph.OnlineMeeting> GetOnlineMeetingAsync(string tenantId, string meetingId)
public static async Task<Microsoft.Graph.OnlineMeeting> GetOnlineMeetingByVtcIdAsync(string tenantId, string videoTeleconferenceId)
{
var name = typeof(Program).Assembly.GetName().Name;
var logger = new GraphLogger(name);
var onlineMeeting = new OnlineMeeting(
new AuthenticationProvider(name, appId, appSecret, logger),
graphUri);

var meetingDetails = await onlineMeeting.GetOnlineMeetingAsync(tenantId, meetingId, default(Guid)).ConfigureAwait(false);
var meetingDetails = await onlineMeeting.GetOnlineMeetingByVtcIdAsync(tenantId, videoTeleconferenceId, default(Guid)).ConfigureAwait(false);

Console.WriteLine(meetingDetails.Id);
Console.WriteLine(meetingDetails.ChatInfo.ThreadId);
Expand Down Expand Up @@ -78,7 +78,7 @@ public static void Main(string[] args)
{
try
{
var meetingDetails = await GetOnlineMeetingAsync(tenantId, meetingId).ConfigureAwait(false);
var meetingDetails = await GetOnlineMeetingByVtcIdAsync(tenantId, vtcId).ConfigureAwait(false);

var createdMeetingDetails = await CreateOnlineMeetingAsync(tenantId, organizerID).ConfigureAwait(false);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
// <copyright file="UserPasswordAuthenticationProvider.cs" company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
// </copyright>

namespace OnlineMeeting
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Microsoft.Graph.Communications.Client.Authentication;
using Microsoft.Graph.Communications.Common;
using Microsoft.Graph.Communications.Common.Telemetry;
using Newtonsoft.Json;

/// <summary>
/// Authentication provider to add .
/// </summary>
public class UserPasswordAuthenticationProvider : ObjectRoot, IRequestAuthenticationProvider
{
/// <summary>
/// Initializes a new instance of the <see cref="UserPasswordAuthenticationProvider"/> class.
/// </summary>
/// <param name="appId">The application identifier.</param>
/// <param name="appSecret">The application secret.</param>
/// <param name="userName">The username to be used.</param>
/// <param name="password">Password assoicated with the passed username.</param>
/// <param name="logger">The logger.</param>
public UserPasswordAuthenticationProvider(string appId, string appSecret, string userName, string password, IGraphLogger logger)
: base(logger.NotNull(nameof(logger)).CreateShim(nameof(UserPasswordAuthenticationProvider)))
{
Debug.Assert(!string.IsNullOrWhiteSpace(appId), $"Invalid {nameof(appId)}.");
Debug.Assert(!string.IsNullOrWhiteSpace(appSecret), $"Invalid {nameof(appSecret)}.");
Debug.Assert(!string.IsNullOrWhiteSpace(userName), $"Invalid {nameof(userName)}.");
Debug.Assert(!string.IsNullOrWhiteSpace(password), $"Invalid {nameof(password)}.");

this.AppId = appId;
this.AppSecret = appSecret;

// NOTE: STORING USERNAME/PASSWORD IN A FILE IS NOT SAFE. THIS SAMPLE IS FOR DEMONSTRATION PURPOSE ONLY.
this.UserName = userName;
this.Password = password;
}

/// <summary>
/// Gets the application identifier.
/// </summary>
/// <value>
/// The application identifier.
/// </value>
private string AppId { get; }

/// <summary>
/// Gets the application secret.
/// </summary>
/// <value>
/// The application secret.
/// </value>
private string AppSecret { get; }

/// <summary>
/// Gets UserName to be passed to oauth service.
/// </summary>
private string UserName { get; }

/// <summary>
/// Gets password to be passed to oauth service.
/// </summary>
private string Password { get; }

/// <inheritdoc />
public async Task AuthenticateOutboundRequestAsync(HttpRequestMessage request, string tenantId)
{
Debug.Assert(!string.IsNullOrWhiteSpace(tenantId), $"Invalid {nameof(tenantId)}.");

const string BearerPrefix = "Bearer";
const string ReplaceString = "{tenant}";
const string TokenAuthorityMicrosoft = "https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token";
const string Resource = @"https://graph.microsoft.com";

var tokenLink = TokenAuthorityMicrosoft.Replace(ReplaceString, tenantId);
OAuthResponse authResult = null;

try
{
using (var httpClient = new HttpClient())
{
var result1 = await httpClient.PostAsync(tokenLink, new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("resource", Resource),
new KeyValuePair<string, string>("client_id", this.AppId),
new KeyValuePair<string, string>("grant_type", "password"),
new KeyValuePair<string, string>("username", this.UserName),
new KeyValuePair<string, string>("password", this.Password),
new KeyValuePair<string, string>("scope", "openid"),
new KeyValuePair<string, string>("client_secret", this.AppSecret),
})).ConfigureAwait(false);

var content = await result1.Content.ReadAsStringAsync().ConfigureAwait(false);
authResult = JsonConvert.DeserializeObject<OAuthResponse>(content);

request.Headers.Authorization = new AuthenticationHeaderValue(BearerPrefix, authResult.Access_Token);
}
}
catch (Exception ex)
{
this.GraphLogger.Error(ex, $"Failed to generate user token for user: {this.UserName}");
throw;
}

this.GraphLogger.Info($"Generated OAuth token. Expires in {authResult.Expires_In / 60} minutes.");
}

/// <inheritdoc />
public Task<RequestValidationResult> ValidateInboundRequestAsync(HttpRequestMessage request)
{
throw new NotImplementedException();
}

/// <summary>
/// Response received from oauth service.
/// </summary>
private class OAuthResponse
{
/// <summary>
/// Gets or Sets access token.
/// </summary>
public string Access_Token { get; set; }

/// <summary>
/// Gets or Sets expires time.
/// </summary>
public int Expires_In { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Sample.Common.OnlineMeetings
using System.Threading.Tasks;
using Microsoft.Graph;
using Microsoft.Graph.Communications.Client.Authentication;
using Microsoft.Graph.Communications.Core;
using Microsoft.Graph.Communications.Common;

/// <summary>
/// Online meeting class to fetch meeting info based of meeting id (ex: vtckey).
Expand Down Expand Up @@ -43,8 +43,8 @@ IAuthenticationProvider GetAuthenticationProvider()
{
return new DelegateAuthenticationProvider(async request =>
{
request.Headers.Add(CommsConstants.Headers.ScenarioId, scenarioId.ToString());
request.Headers.Add(CommsConstants.Headers.ClientRequestId, Guid.NewGuid().ToString());
request.Headers.Add(HttpConstants.HeaderNames.ScenarioId, scenarioId.ToString());
request.Headers.Add(HttpConstants.HeaderNames.ClientRequestId, Guid.NewGuid().ToString());

await this.requestAuthenticationProvider
.AuthenticateOutboundRequestAsync(request, tenantId)
Expand Down
4 changes: 2 additions & 2 deletions Samples/Common/Sample.Common/Sample.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<Import Project="$(MSBuildThisFileDirectory)..\..\Graph.props" />

<ItemGroup>
<PackageReference Include="Microsoft.Graph.Communications.Client" Version="1.1.0-prerelease.581" />
<PackageReference Include="Microsoft.Graph.Communications.Core.Calls" Version="1.1.0-prerelease.581" />
<PackageReference Include="Microsoft.Graph.Communications.Client" Version="1.1.0-prerelease.1511" />
<PackageReference Include="Microsoft.Graph.Communications.Core.Calls" Version="1.1.0-prerelease.1511" />
<PackageReference Include="Microsoft.IdentityModel.Clients.ActiveDirectory" Version="5.1.0" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="5.5.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@
<ItemGroup>
<Reference Include="Microsoft.Skype.Internal.Media.H264, Version=0.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\packages\Microsoft.Skype.Bots.Media\1.13.1.98-alpha\src\skype_media_lib\Microsoft.Skype.Internal.Media.H264.dll</HintPath>
<HintPath>..\..\..\..\packages\Microsoft.Skype.Bots.Media\1.13.1.324-alpha\src\skype_media_lib\Microsoft.Skype.Internal.Media.H264.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.Owin" Version="5.2.7" />
<PackageReference Include="Microsoft.Graph.Communications.Calls.Media" Version="1.1.0-prerelease.581" />
<PackageReference Include="Microsoft.Graph.Communications.Calls.Media" Version="1.1.0-prerelease.1511" />
<PackageReference Include="Microsoft.Owin.Hosting" Version="4.0.1" />
<PackageReference Include="Microsoft.Skype.Bots.Media" Version="1.13.1.98-alpha" />
<PackageReference Include="Microsoft.Skype.Bots.Media" Version="1.13.1.324-alpha" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<Reference Include="System.Data.Entity" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ namespace Sample.AudioVideoPlaybackBot.FrontEnd.Http
using System.Net.Http.Headers;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Graph.Communications.Common;
using Microsoft.Graph.Communications.Common.Telemetry;
using Microsoft.Graph.Communications.Core;

/// <summary>
/// Helper class to log HTTP requests and responses and to set the scenario id based on the Scenario-ID or the X-Microsoft-Skype-Chain-ID headers
Expand Down Expand Up @@ -206,12 +206,12 @@ private string AdoptScenarioId(HttpHeaders headers)
IEnumerable<string> values;
Guid scenarioGuid;
string scenarioId = null;
if (headers.TryGetValues(CommsConstants.Headers.ScenarioId, out values) && Guid.TryParse(values.FirstOrDefault(), out scenarioGuid))
if (headers.TryGetValues(HttpConstants.HeaderNames.ScenarioId, out values) && Guid.TryParse(values.FirstOrDefault(), out scenarioGuid))
{
scenarioId = scenarioGuid.ToString();
this.logger.CorrelationId = scenarioGuid;
}
else if (headers.TryGetValues(CommsConstants.Headers.ChainId, out values) && Guid.TryParse(values.FirstOrDefault(), out scenarioGuid))
else if (headers.TryGetValues(HttpConstants.HeaderNames.ChainId, out values) && Guid.TryParse(values.FirstOrDefault(), out scenarioGuid))
{
scenarioId = scenarioGuid.ToString();
this.logger.CorrelationId = scenarioGuid;
Expand All @@ -234,7 +234,7 @@ private string SetScenarioId(HttpHeaders headers)
Guid scenarioId = this.logger.CorrelationId;
if (scenarioId != Guid.Empty)
{
headers.Add(CommsConstants.Headers.ScenarioId, scenarioId.ToString());
headers.Add(HttpConstants.HeaderNames.ScenarioId, scenarioId.ToString());
}

return scenarioId.ToString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Data.Services.Client" Version="5.8.4" />
<PackageReference Include="Microsoft.Owin.Host.HttpListener" Version="4.0.1" />
<PackageReference Include="Microsoft.Skype.Bots.Media" Version="1.13.1.98-alpha" />
<PackageReference Include="Microsoft.Skype.Bots.Media" Version="1.13.1.324-alpha" />
<PackageReference Include="Microsoft.WindowsAzure.ConfigurationManager" Version="3.2.3" />
<PackageReference Include="Microsoft.WindowsAzure.SDK" Version="2.9.0" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Skype.Bots.Media" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.13.1.98" newVersion="1.13.1.98" />
<bindingRedirect oldVersion="0.0.0.0-1.13.1.324" newVersion="1.13.1.324" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<PackageReference Include="Microsoft.ServiceFabric.AspNetCore.HttpSys" Version="3.2.176" />
<!-- Although Bots.Media is implicitly imported by Calls.Media, this library requires an explicit reference for
some scripts included within the nuget package. -->
<PackageReference Include="Microsoft.Skype.Bots.Media" Version="1.13.1.98-alpha" />
<PackageReference Include="Microsoft.Graph.Communications.Calls.Media" Version="1.1.0-prerelease.581" />
<PackageReference Include="Microsoft.Skype.Bots.Media" Version="1.13.1.324-alpha" />
<PackageReference Include="Microsoft.Graph.Communications.Calls.Media" Version="1.1.0-prerelease.1511" />
</ItemGroup>

<ItemGroup>
Expand Down
16 changes: 16 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

This changelog covers what's changed in Microsoft Graph Communications SDK and its associated samples.

## Sept 2019

- Updated Media library 1.13.1.324-alpha
- Updated Communications libraries 1.1.0-prerelease.1511

### Communications 1.1.0-prerelease.1511 Changes

- Updated to latest /beta contacts.
- For a full list of changes refer to the [graph blog](https://developer.microsoft.com/en-us/graph/blogs/breaking-changes-calls-and-online-meetings-api-updates-in-microsoft-graph-beta/).
- Stateful client now supports HA/DR.
- Further detail to come in sample and SDK documentation.
- Added more verbose code comments.
- Removed redundant objects.
- Removed obsolete objects.
- Misc bug fixes and improvements.

## June 2019

- Migrated AuthenticationProvider from ADAL to MSAL AAD libraries.
Expand Down
Loading