PTI.Microservices.Library.MicrosoftGraph 7.0.0.1

dotnet add package PTI.Microservices.Library.MicrosoftGraph --version 7.0.0.1                
NuGet\Install-Package PTI.Microservices.Library.MicrosoftGraph -Version 7.0.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PTI.Microservices.Library.MicrosoftGraph" Version="7.0.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PTI.Microservices.Library.MicrosoftGraph --version 7.0.0.1                
#r "nuget: PTI.Microservices.Library.MicrosoftGraph, 7.0.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PTI.Microservices.Library.MicrosoftGraph as a Cake Addin
#addin nuget:?package=PTI.Microservices.Library.MicrosoftGraph&version=7.0.0.1

// Install PTI.Microservices.Library.MicrosoftGraph as a Cake Tool
#tool nuget:?package=PTI.Microservices.Library.MicrosoftGraph&version=7.0.0.1                

PTI.Microservices.Library.MicrosoftGraph

This is part of PTI.Microservices.Library set of packages

The purpose of this package is to facilitate the calls to Microsoft Graph APIs, while maintaining a consistent usage pattern among the different services in the group

Examples:

Create User

CustomHttpClient customHttpClient = new CustomHttpClient(new CustomHttpClientHandler(null));
MicrosoftGraphService microsoftGraphService = new MicrosoftGraphService(null,
    this.MicrosoftGraphConfiguration, customHttpClient);
var result = await microsoftGraphService.GetAppTokenAsync();
Assert.IsNotNull(result);
CreateUserRequest createUserRequest =
    new CreateUserRequest()
    {
        accountEnabled = true,
        displayName = TEST_DISPLAY_NAME,
        mailNickname = TEST_MAIL_NICKNAME,
        givenName = TEST_GIVEN_NAME,
        surName = TEST_SURNAME,
        //userPrincipalName = TEST_USER_PRINCIPAL_NAME,
        identities = new Identity[] {
            new Identity()
            {
                signInType="emailAddress",
                issuer=TEST_ISSUER,
                issuerAssignedId=TEST_ISSUER_ASSIGNED_ID,
            }
        },
        passwordProfile = new Passwordprofile()
        {
            password = TEST_PASSWORD,
            forceChangePasswordNextSignIn = false,
        },
        passwordPolicies = "DisablePasswordExpiration"
    };

var createdUser = 
    await microsoftGraphService.CreateB2CUserAsync(result.access_token, createUserRequest);

Get Users

CustomHttpClient customHttpClient = new CustomHttpClient(new CustomHttpClientHandler(null));
MicrosoftGraphService microsoftGraphService = new MicrosoftGraphService(null,
    this.MicrosoftGraphConfiguration, customHttpClient);
var getAppTokenResult = await microsoftGraphService.GetAppTokenAsync();
var result = await microsoftGraphService.GetUsersAsync(getAppTokenResult.access_token);

Get Applications

CustomHttpClient customHttpClient = new CustomHttpClient(new CustomHttpClientHandler(null));
MicrosoftGraphService microsoftGraphService = new MicrosoftGraphService(null,
    this.MicrosoftGraphConfiguration, customHttpClient);
var getAppTokenResult = await microsoftGraphService.GetAppTokenAsync();
var result = await microsoftGraphService.GetApplicationsAsync(getAppTokenResult.access_token);

Update Application Roles

var ptiserverApp = await microsoftGraphService.GetApplicationAsync(getAppTokenResult.access_token,
    Guid.Parse(TEST_APPLICATION_ID));
ptiserverApp.appRoles = new Microservices.Library.Models.MicrosoftGraphService.GetApplication.Approle[]
{
    new Microservices.Library.Models.MicrosoftGraphService.GetApplication.Approle()
    {
        description="Test Role Desc",
        displayName="Test Role Display Name",
        id=Guid.NewGuid().ToString(),
        isEnabled=true,
        value="TestRoleClaimValue",
        allowedMemberTypes = new string[]{"User" }//["User","Application"]
    }
};
await microsoftGraphService.UpdateApplicationRolesAsync(getAppTokenResult.access_token,
    Guid.Parse(ptiserverApp.id), ptiserverApp.appRoles.ToList());
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
7.0.0.1 374 11/14/2022
7.0.0 329 11/13/2022
2.0.0.1-preview 213 10/7/2021
2.0.0-preview 271 7/9/2021