MicrosoftDocs / feedback

📢 docs.microsoft.com site feedback
https://learn.microsoft.com
Creative Commons Attribution 4.0 International
239 stars 160 forks source link

'ClaimsPrincipal' does not contain a definition for 'GetUserGraphTimeZone' #3157

Open mjosborne1 opened 4 years ago

mjosborne1 commented 4 years ago

Describe the bug https://docs.microsoft.com/en-us/graph/tutorials/aspnet-core?tutorial-step=4 Everywhere that I try to get the User Timezone in this tutorial using User.GetUserGraphTimeZone() I see this error

Severity Code Description Project File Line Suppression State Error CS1061 'ClaimsPrincipal' does not contain a definition for 'GetUserGraphTimeZone' and no accessible extension method 'GetUserGraphTimeZone' accepting a first argument of type 'ClaimsPrincipal' could be found (are you missing a using directive or an assembly reference?) TableBookings C:\Code\www\azure\TableBookings\Controllers\CalendarController.cs 34 Active

e.g. using TableBookings.Models; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Microsoft.Identity.Web; using System.Security.Claims; using Microsoft.Graph; using System; using System.Collections.Generic; using System.Threading.Tasks;

// Minimum permission scope needed for this view [AuthorizeForScopes(Scopes = new[] { "Calendars.Read" })] public async Task Index() { try { var userTimeZone = TimeZoneInfo.FindSystemTimeZoneById( User.GetUserGraphTimeZone()); var startOfWeek = CalendarController.GetUtcStartOfWeekInTimeZone( DateTime.Today, userTimeZone);

            var events = await GetUserWeekCalendar(startOfWeek);

            var model = new CalendarViewModel(startOfWeek, events);

            return View(model);
        }
        catch (ServiceException ex)
        {           

            return View(new CalendarViewModel())
                .WithError("Error getting calendar view", ex.Message);
        }
    }

To Reproduce Steps to reproduce the behavior:

  1. Follow tutorial

Desktop (please complete the following information):

Installed Version: Professional

ADL Tools Service Provider 1.0 This package contains services used by Data Lake tools

ASA Service Provider 1.0

ASP.NET and Web Tools 2019 16.7.532.28833 ASP.NET and Web Tools 2019

ASP.NET Core Razor Language Services 16.1.0.2035807+72d099b977d3a85e65fa3b0614ca8cfc803fef02 Provides languages services for ASP.NET Core Razor.

ASP.NET Web Frameworks and Tools 2019 16.7.532.28833 For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0 16.7.532.28833 Azure App Service Tools v3.0.0

Azure Data Lake Node 1.0 This package contains the Data Lake integration nodes for Server Explorer.

Azure Data Lake Tools for Visual Studio 2.4.6000.0 Microsoft Azure Data Lake Tools for Visual Studio

Azure Functions and Web Jobs Tools 16.7.532.28833 Azure Functions and Web Jobs Tools

Azure Stream Analytics Tools for Visual Studio 2.4.6000.0 Microsoft Azure Stream Analytics Tools for Visual Studio

C# Tools 3.7.0-6.20459.4+7ee7c540e3bf19765695b1331c946ddf986d1516 C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Cookiecutter 16.7.20248.6 Provides tools for finding, instantiating and customizing templates in cookiecutter format.

Fabric.DiagnosticEvents 1.0 Fabric Diagnostic Events

GitHub.VisualStudio 2.11.106.19330 A Visual Studio Extension that brings the GitHub Flow into Visual Studio.

IntelliCode Extension 1.0 IntelliCode Visual Studio Extension Detailed Info

Microsoft Azure HDInsight Azure Node 2.4.6000.0 HDInsight Node under Azure Node

Microsoft Azure Hive Query Language Service 2.4.6000.0 Language service for Hive query

Microsoft Azure Service Fabric Tools for Visual Studio 16.0 Microsoft Azure Service Fabric Tools for Visual Studio

Microsoft Azure Stream Analytics Language Service 2.4.6000.0 Language service for Azure Stream Analytics

Microsoft Azure Stream Analytics Node 1.0 Azure Stream Analytics Node under Azure Node

Microsoft Azure Tools 2.9 Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.30701.1

Microsoft Continuous Delivery Tools for Visual Studio 0.4 Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.

Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager 2.1.79+ge3567815aa.RR Install client-side libraries easily to any web project

Microsoft MI-Based Debugger 1.0 Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio Tools for Containers 1.1 Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Node.js Tools 1.5.20701.1 Commit Hash:b0da3724234b78593207434292d9f891440edea1 Adds support for developing and debugging Node.js apps in Visual Studio

NuGet Package Manager 5.7.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

ProjectServicesPackage Extension 1.0 ProjectServicesPackage Visual Studio Extension Detailed Info

Python 16.7.20248.6 Provides IntelliSense, projects, templates, debugging, interactive windows, and other support for Python developers.

Python - Conda support 16.7.20248.6 Conda support for Python projects.

Python - Django support 16.7.20248.6 Provides templates and integration for the Django web framework.

Python - IronPython support 16.7.20248.6 Provides templates and integration for IronPython-based projects.

Python - Profiling support 16.7.20248.6 Profiling support for Python projects.

SQL Server Data Tools 16.0.62008.03130 Microsoft SQL Server Data Tools

ToolWindowHostedEditor 1.0 Hosting json editor into a tool window

TypeScript Tools 16.0.20702.2001 TypeScript Tools for Microsoft Visual Studio

UpgradeCommand Extension 1.0 UpgradeCommand Visual Studio Extension Detailed Info

Visual Basic Tools 3.7.0-6.20459.4+7ee7c540e3bf19765695b1331c946ddf986d1516 Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 10.10.0.0 for F# 4.7 16.7.0-beta.20361.3+3ef6f0b514198c0bfa6c2c09fefe41a740b024d5 Microsoft Visual F# Tools 10.10.0.0 for F# 4.7

Visual Studio Code Debug Adapter Host Package 1.0 Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Container Tools Extensions (Preview) 1.0 View, manage, and diagnose containers within Visual Studio.

Visual Studio Tools for Containers 1.0 Visual Studio Tools for Containers

Visual Studio Tools for Kubernetes 1.0 Visual Studio Tools for Kubernetes

welcome[bot] commented 4 years ago

Thank you for creating the issue! One of our team members will get back to you shortly with additional information. If this is a product issue, please close this and contact the particular product's support instead (see https://support.microsoft.com/allproducts for the list of support websites).

rootsmusic commented 3 years ago

@mjosborne1 Please move this issue to https://github.com/microsoftgraph/microsoft-graph-docs/issues

hazigin commented 2 years ago

Please Add This code to _Imports.razor

@using GraphTutorial.Graph