Giter VIP home page Giter VIP logo

msgraph-sample-angularspa's Introduction

page_type description products languages
sample
This sample demonstrates how to use the Microsoft Graph JavaScript SDK to access data in Office 365 from Angular single-page applications.
ms-graph
office-exchange-online
typescript

Microsoft Graph sample Angular app

Node.js CI License.

This sample demonstrates how to use the Microsoft Graph JavaScript SDK to access data in Office 365 from Angular single-page applications.

NOTE: This sample was originally built from a tutorial published on the Microsoft Graph tutorials page. That tutorial has been removed.

Prerequisites

To run the completed project in this folder, you need the following:

  • Node.js installed on your development machine. If you do not have Node.js, visit the previous link for download options. (Note: This tutorial was written with Node version 16.4.2. The steps in this guide may work with other versions, but that has not been tested.)
  • Angular CLI installed on your development machine.
  • Either a personal Microsoft account with a mailbox on Outlook.com, or a Microsoft work or school account.

If you don't have a Microsoft account, there are a couple of options to get a free account:

Register a web application with the Azure Active Directory admin center

  1. Open a browser and navigate to the Azure Active Directory admin center. Login using a personal account (aka: Microsoft Account) or Work or School Account.

  2. Select Azure Active Directory in the left-hand navigation, then select App registrations under Manage

  3. Select New registration. On the Register an application page, set the values as follows.

    • Set Name to Angular Graph Sample.
    • Set Supported account types to Accounts in any organizational directory and personal Microsoft accounts.
    • Under Redirect URI, set the first drop-down to Single-page application (SPA) and set the value to http://localhost:4200.
  4. Choose Register. On the Angular Graph Tutorial page, copy the value of the Application (client) ID and save it, you will need it in the next step.

Configure the sample

  1. Rename the oauth.example.ts file to oauth.ts.

  2. Edit the oauth.ts file and make the following changes.

    1. Replace YOUR_APP_ID_HERE with the Application Id you got from the App Registration Portal.
  3. In your command-line interface (CLI), navigate to this directory and run the following command to install requirements.

    npm install

Run the sample

  1. Run the following command in your CLI to start the application.

    ng serve
  2. Open a browser and browse to http://localhost:4200.

Code of conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Disclaimer

THIS CODE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.

msgraph-sample-angularspa's People

Contributors

andrewconnell avatar dependabot[bot] avatar github-actions[bot] avatar jackson-woods avatar jasonjoh avatar jshinevar avatar jthake-msft avatar juliemturner avatar microsoft-github-policy-service[bot] avatar msftbot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

msgraph-sample-angularspa's Issues

Getting Error while login

Thank you for taking an interest in Microsoft Graph development! Please feel free to ask a question here, but keep in mind the following:

  • This is not an official Microsoft support channel, and our ability to respond to questions here is limited. Questions about Graph, or questions about adding a new feature to the sample, will be answered on a best-effort basis.
  • Questions should be asked on Stack Overflow.
  • Issues with Microsoft Graph itself should be handled through support.

Issue with @azure/msal-angular 0.1.4 using Angular 9.0.2

When adding in the import below:

MsalModule.forRoot({
  clientID: OAuthSettings.appId
})

the following error is thrown:

ERROR in node_modules/@azure/msal-angular/dist/msal.module.d.ts:6:41 - error NG6005: MsalModule.forRoot returns a ModuleWithProviders type without a generic type argument. Please add a generic type argument to the ModuleWithProviders type. If this occurrence is in library code you don't control, please contact the library authors.

Cheers

sample code won't run

Hello,

getting this error while trying to run it. I guess I am missing install for OAuthSettings.
Can you help?

ERROR in src/app/auth.service.ts:9:31 - error TS2307: Cannot find module '../oauth'.

9 import { OAuthSettings } from '../oauth';
~~~~~~~~~~
src/app/app.module.ts:17:31 - error TS2307: Cannot find module '../oauth'.

17 import { OAuthSettings } from '../oauth';

Avatar?

Browser gives in console a TypeError: Cannot read property 'avatar' of undefined
It seems avatar is no longer a property of /me
Do we need to work it around to /me/photo?

Missing install command, Typo in Typescript code

Copied from MicrosoftDocs/feedback#968

Link to article:
https://docs.microsoft.com/en-us/graph/tutorials/angular?tutorial-step=1

Problem:

Missing
(ERROR in src/app/app.module.ts(1,27): error TS2307: Cannot find module '@ng-bootstrap/ng-bootstrap'.):

npm install --save @ng-bootstrap/ng-bootstrap

Typo

(AppRoutingModule is written twice):

imports: [ BrowserModule, AppRoutingModule AppRoutingModule, NgbModule, FontAwesomeModule ]

Should be:

imports: [ BrowserModule, AppRoutingModule, NgbModule, FontAwesomeModule ]

Typo

(In both nav-bar.component.ts and home.component.ts, tslint wants ' rather than "):

signIn(): void { 
  // Temporary this.authenticated = true; 
  this.user = { displayName: "Adele Vance", email: "[email protected]" }; 
}

Should be:

signIn(): void { 
  // Temporary this.authenticated = true; 
  this.user = { displayName: 'Adele Vance', email: '[email protected]' }; 
}

Some console errors.

A minor point, but due to some asynchronicity you could add some *ngIf guard clauses so that displayName/avatar is only read once authService.user has been returned by the authService to get rid of these annoying console errors:

ERROR TypeError: Cannot read property 'displayName' of undefined
    at Object.eval [as updateRenderer] (HomeComponent.html:6)
ERROR TypeError: Cannot read property 'avatar' of undefined
    at Object.eval [as updateDirectives] (NavBarComponent.html:26)

After Logging In it is showing

Thank you for taking an interest in Microsoft Graph development! Please feel free to ask a question here, but keep in mind the following:

  • This is not an official Microsoft support channel, and our ability to respond to questions here is limited. Questions about Graph, or questions about adding a new feature to the sample, will be answered on a best-effort basis.
  • Questions should be asked on Stack Overflow.
  • Issues with Microsoft Graph itself should be handled through support.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.