├── .gitignore ├── 01 httpclient.pptx ├── 02 aadhttpclient.pptx ├── 03 msgraphpclient.pptx ├── Demos ├── 01-httpclient │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmignore │ ├── .vscode │ │ ├── launch.json │ │ └── settings.json │ ├── .yo-rc.json │ ├── README.md │ ├── config │ │ ├── config.json │ │ ├── deploy-azure-storage.json │ │ ├── package-solution.json │ │ ├── sass.json │ │ ├── serve.json │ │ └── write-manifests.json │ ├── gulpfile.js │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── index.ts │ │ ├── models │ │ │ └── INasaImageSearchResponse.ts │ │ └── webparts │ │ │ └── spFxHttpClient │ │ │ ├── SpFxHttpClientWebPart.manifest.json │ │ │ ├── SpFxHttpClientWebPart.ts │ │ │ ├── assets │ │ │ ├── welcome-dark.png │ │ │ └── welcome-light.png │ │ │ ├── components │ │ │ ├── ISpFxHttpClientProps.ts │ │ │ ├── SpFxHttpClient.module.scss │ │ │ └── SpFxHttpClient.tsx │ │ │ └── loc │ │ │ ├── en-us.js │ │ │ └── mystrings.d.ts │ ├── teams │ │ ├── ff9096ee-7b9d-48ce-bb58-00f807bcc180_color.png │ │ └── ff9096ee-7b9d-48ce-bb58-00f807bcc180_outline.png │ └── tsconfig.json ├── 02-aadhttpclient │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmignore │ ├── .vscode │ │ ├── launch.json │ │ └── settings.json │ ├── .yo-rc.json │ ├── README.md │ ├── config │ │ ├── config.json │ │ ├── deploy-azure-storage.json │ │ ├── package-solution.json │ │ ├── sass.json │ │ ├── serve.json │ │ └── write-manifests.json │ ├── gulpfile.js │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── index.ts │ │ ├── models │ │ │ └── IUserItem.ts │ │ └── webparts │ │ │ └── spFxAadHttpClient │ │ │ ├── SpFxAadHttpClientWebPart.manifest.json │ │ │ ├── SpFxAadHttpClientWebPart.ts │ │ │ ├── assets │ │ │ ├── welcome-dark.png │ │ │ └── welcome-light.png │ │ │ ├── components │ │ │ ├── ISpFxAadHttpClientProps.ts │ │ │ ├── SpFxAadHttpClient.module.scss │ │ │ └── SpFxAadHttpClient.tsx │ │ │ └── loc │ │ │ ├── en-us.js │ │ │ └── mystrings.d.ts │ ├── teams │ │ ├── b37c4dcf-3f2d-4539-a2cd-9afa00e818a5_color.png │ │ └── b37c4dcf-3f2d-4539-a2cd-9afa00e818a5_outline.png │ └── tsconfig.json ├── 03-msgraphclient │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmignore │ ├── .vscode │ │ ├── launch.json │ │ └── settings.json │ ├── .yo-rc.json │ ├── README.md │ ├── config │ │ ├── config.json │ │ ├── deploy-azure-storage.json │ │ ├── package-solution.json │ │ ├── sass.json │ │ ├── serve.json │ │ └── write-manifests.json │ ├── gulpfile.js │ ├── package.json │ ├── src │ │ ├── index.ts │ │ └── webparts │ │ │ └── graphPersona │ │ │ ├── GraphPersonaWebPart.manifest.json │ │ │ ├── GraphPersonaWebPart.ts │ │ │ ├── assets │ │ │ ├── welcome-dark.png │ │ │ └── welcome-light.png │ │ │ ├── components │ │ │ ├── GraphPersona.module.scss │ │ │ ├── GraphPersona.tsx │ │ │ └── IGraphPersonaProps.ts │ │ │ └── loc │ │ │ ├── en-us.js │ │ │ └── mystrings.d.ts │ ├── teams │ │ ├── 10fb665f-3fd8-411c-b68c-947c865d58f6_color.png │ │ └── 10fb665f-3fd8-411c-b68c-947c865d58f6_outline.png │ └── tsconfig.json └── README.md ├── Images ├── aad-addpackage-01.png ├── aad-addpackage-02.png ├── aad-addpackage-03.png ├── aad-addpackage-04.png ├── aad-addpackage-05.png ├── aad-addpackage-06.png ├── aad-addpackage-07.png ├── graph-persona-01.png ├── graph-persona-02.png ├── graph-persona-03.png ├── graph-test-01.png ├── http-client-test-01.png ├── http-client-test-02.png ├── http-client-test-03.png ├── spo-admin-portal-01.png ├── spo-admin-portal-02.png ├── spo-admin-portal-03.png ├── spo-admin-portal-04.png ├── tenant-app-catalog-01.png └── tenant-app-catalog-02.png ├── LICENSE ├── README.md └── SECURITY.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (https://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # TypeScript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | # next.js build output 61 | .next 62 | 63 | .DS_Store -------------------------------------------------------------------------------- /01 httpclient.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/01 httpclient.pptx -------------------------------------------------------------------------------- /02 aadhttpclient.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/02 aadhttpclient.pptx -------------------------------------------------------------------------------- /03 msgraphpclient.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/03 msgraphpclient.pptx -------------------------------------------------------------------------------- /Demos/01-httpclient/.eslintrc.js: -------------------------------------------------------------------------------- 1 | require('@rushstack/eslint-config/patch/modern-module-resolution'); 2 | module.exports = { 3 | extends: ['@microsoft/eslint-config-spfx/lib/profiles/react'], 4 | parserOptions: { tsconfigRootDir: __dirname }, 5 | overrides: [ 6 | { 7 | files: ['*.ts', '*.tsx'], 8 | parser: '@typescript-eslint/parser', 9 | 'parserOptions': { 10 | 'project': './tsconfig.json', 11 | 'ecmaVersion': 2018, 12 | 'sourceType': 'module' 13 | }, 14 | rules: { 15 | // Prevent usage of the JavaScript null value, while allowing code to access existing APIs that may require null. https://www.npmjs.com/package/@rushstack/eslint-plugin 16 | '@rushstack/no-new-null': 1, 17 | // Require Jest module mocking APIs to be called before any other statements in their code block. https://www.npmjs.com/package/@rushstack/eslint-plugin 18 | '@rushstack/hoist-jest-mock': 1, 19 | // Require regular expressions to be constructed from string constants rather than dynamically building strings at runtime. https://www.npmjs.com/package/@rushstack/eslint-plugin-security 20 | '@rushstack/security/no-unsafe-regexp': 1, 21 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 22 | '@typescript-eslint/adjacent-overload-signatures': 1, 23 | // RATIONALE: Code is more readable when the type of every variable is immediately obvious. 24 | // Even if the compiler may be able to infer a type, this inference will be unavailable 25 | // to a person who is reviewing a GitHub diff. This rule makes writing code harder, 26 | // but writing code is a much less important activity than reading it. 27 | // 28 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 29 | '@typescript-eslint/explicit-function-return-type': [ 30 | 1, 31 | { 32 | 'allowExpressions': true, 33 | 'allowTypedFunctionExpressions': true, 34 | 'allowHigherOrderFunctions': false 35 | } 36 | ], 37 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 38 | // Rationale to disable: although this is a recommended rule, it is up to dev to select coding style. 39 | // Set to 1 (warning) or 2 (error) to enable. 40 | '@typescript-eslint/explicit-member-accessibility': 0, 41 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 42 | '@typescript-eslint/no-array-constructor': 1, 43 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 44 | // 45 | // RATIONALE: The "any" keyword disables static type checking, the main benefit of using TypeScript. 46 | // This rule should be suppressed only in very special cases such as JSON.stringify() 47 | // where the type really can be anything. Even if the type is flexible, another type 48 | // may be more appropriate such as "unknown", "{}", or "Record". 49 | '@typescript-eslint/no-explicit-any': 1, 50 | // RATIONALE: The #1 rule of promises is that every promise chain must be terminated by a catch() 51 | // handler. Thus wherever a Promise arises, the code must either append a catch handler, 52 | // or else return the object to a caller (who assumes this responsibility). Unterminated 53 | // promise chains are a serious issue. Besides causing errors to be silently ignored, 54 | // they can also cause a NodeJS process to terminate unexpectedly. 55 | '@typescript-eslint/no-floating-promises': 2, 56 | // RATIONALE: Catches a common coding mistake. 57 | '@typescript-eslint/no-for-in-array': 2, 58 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 59 | '@typescript-eslint/no-misused-new': 2, 60 | // RATIONALE: The "namespace" keyword is not recommended for organizing code because JavaScript lacks 61 | // a "using" statement to traverse namespaces. Nested namespaces prevent certain bundler 62 | // optimizations. If you are declaring loose functions/variables, it's better to make them 63 | // static members of a class, since classes support property getters and their private 64 | // members are accessible by unit tests. Also, the exercise of choosing a meaningful 65 | // class name tends to produce more discoverable APIs: for example, search+replacing 66 | // the function "reverse()" is likely to return many false matches, whereas if we always 67 | // write "Text.reverse()" is more unique. For large scale organization, it's recommended 68 | // to decompose your code into separate NPM packages, which ensures that component 69 | // dependencies are tracked more conscientiously. 70 | // 71 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 72 | '@typescript-eslint/no-namespace': [ 73 | 1, 74 | { 75 | 'allowDeclarations': false, 76 | 'allowDefinitionFiles': false 77 | } 78 | ], 79 | // RATIONALE: Parameter properties provide a shorthand such as "constructor(public title: string)" 80 | // that avoids the effort of declaring "title" as a field. This TypeScript feature makes 81 | // code easier to write, but arguably sacrifices readability: In the notes for 82 | // "@typescript-eslint/member-ordering" we pointed out that fields are central to 83 | // a class's design, so we wouldn't want to bury them in a constructor signature 84 | // just to save some typing. 85 | // 86 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 87 | // Set to 1 (warning) or 2 (error) to enable the rule 88 | '@typescript-eslint/parameter-properties': 0, 89 | // RATIONALE: When left in shipping code, unused variables often indicate a mistake. Dead code 90 | // may impact performance. 91 | // 92 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 93 | '@typescript-eslint/no-unused-vars': [ 94 | 1, 95 | { 96 | 'vars': 'all', 97 | // Unused function arguments often indicate a mistake in JavaScript code. However in TypeScript code, 98 | // the compiler catches most of those mistakes, and unused arguments are fairly common for type signatures 99 | // that are overriding a base class method or implementing an interface. 100 | 'args': 'none' 101 | } 102 | ], 103 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 104 | '@typescript-eslint/no-use-before-define': [ 105 | 2, 106 | { 107 | 'functions': false, 108 | 'classes': true, 109 | 'variables': true, 110 | 'enums': true, 111 | 'typedefs': true 112 | } 113 | ], 114 | // Disallows require statements except in import statements. 115 | // In other words, the use of forms such as var foo = require("foo") are banned. Instead use ES6 style imports or import foo = require("foo") imports. 116 | '@typescript-eslint/no-var-requires': 'error', 117 | // RATIONALE: The "module" keyword is deprecated except when describing legacy libraries. 118 | // 119 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 120 | '@typescript-eslint/prefer-namespace-keyword': 1, 121 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 122 | // Rationale to disable: it's up to developer to decide if he wants to add type annotations 123 | // Set to 1 (warning) or 2 (error) to enable the rule 124 | '@typescript-eslint/no-inferrable-types': 0, 125 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 126 | // Rationale to disable: declaration of empty interfaces may be helpful for generic types scenarios 127 | '@typescript-eslint/no-empty-interface': 0, 128 | // RATIONALE: This rule warns if setters are defined without getters, which is probably a mistake. 129 | 'accessor-pairs': 1, 130 | // RATIONALE: In TypeScript, if you write x["y"] instead of x.y, it disables type checking. 131 | 'dot-notation': [ 132 | 1, 133 | { 134 | 'allowPattern': '^_' 135 | } 136 | ], 137 | // RATIONALE: Catches code that is likely to be incorrect 138 | 'eqeqeq': 1, 139 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 140 | 'for-direction': 1, 141 | // RATIONALE: Catches a common coding mistake. 142 | 'guard-for-in': 2, 143 | // RATIONALE: If you have more than 2,000 lines in a single source file, it's probably time 144 | // to split up your code. 145 | 'max-lines': ['warn', { max: 2000 }], 146 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 147 | 'no-async-promise-executor': 2, 148 | // RATIONALE: Deprecated language feature. 149 | 'no-caller': 2, 150 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 151 | 'no-compare-neg-zero': 2, 152 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 153 | 'no-cond-assign': 2, 154 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 155 | 'no-constant-condition': 1, 156 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 157 | 'no-control-regex': 2, 158 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 159 | 'no-debugger': 1, 160 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 161 | 'no-delete-var': 2, 162 | // RATIONALE: Catches code that is likely to be incorrect 163 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 164 | 'no-duplicate-case': 2, 165 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 166 | 'no-empty': 1, 167 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 168 | 'no-empty-character-class': 2, 169 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 170 | 'no-empty-pattern': 1, 171 | // RATIONALE: Eval is a security concern and a performance concern. 172 | 'no-eval': 1, 173 | // RATIONALE: Catches code that is likely to be incorrect 174 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 175 | 'no-ex-assign': 2, 176 | // RATIONALE: System types are global and should not be tampered with in a scalable code base. 177 | // If two different libraries (or two versions of the same library) both try to modify 178 | // a type, only one of them can win. Polyfills are acceptable because they implement 179 | // a standardized interoperable contract, but polyfills are generally coded in plain 180 | // JavaScript. 181 | 'no-extend-native': 1, 182 | // Disallow unnecessary labels 183 | 'no-extra-label': 1, 184 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 185 | 'no-fallthrough': 2, 186 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 187 | 'no-func-assign': 1, 188 | // RATIONALE: Catches a common coding mistake. 189 | 'no-implied-eval': 2, 190 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 191 | 'no-invalid-regexp': 2, 192 | // RATIONALE: Catches a common coding mistake. 193 | 'no-label-var': 2, 194 | // RATIONALE: Eliminates redundant code. 195 | 'no-lone-blocks': 1, 196 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 197 | 'no-misleading-character-class': 2, 198 | // RATIONALE: Catches a common coding mistake. 199 | 'no-multi-str': 2, 200 | // RATIONALE: It's generally a bad practice to call "new Thing()" without assigning the result to 201 | // a variable. Either it's part of an awkward expression like "(new Thing()).doSomething()", 202 | // or else implies that the constructor is doing nontrivial computations, which is often 203 | // a poor class design. 204 | 'no-new': 1, 205 | // RATIONALE: Obsolete language feature that is deprecated. 206 | 'no-new-func': 2, 207 | // RATIONALE: Obsolete language feature that is deprecated. 208 | 'no-new-object': 2, 209 | // RATIONALE: Obsolete notation. 210 | 'no-new-wrappers': 1, 211 | // RATIONALE: Catches code that is likely to be incorrect 212 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 213 | 'no-octal': 2, 214 | // RATIONALE: Catches code that is likely to be incorrect 215 | 'no-octal-escape': 2, 216 | // RATIONALE: Catches code that is likely to be incorrect 217 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 218 | 'no-regex-spaces': 2, 219 | // RATIONALE: Catches a common coding mistake. 220 | 'no-return-assign': 2, 221 | // RATIONALE: Security risk. 222 | 'no-script-url': 1, 223 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 224 | 'no-self-assign': 2, 225 | // RATIONALE: Catches a common coding mistake. 226 | 'no-self-compare': 2, 227 | // RATIONALE: This avoids statements such as "while (a = next(), a && a.length);" that use 228 | // commas to create compound expressions. In general code is more readable if each 229 | // step is split onto a separate line. This also makes it easier to set breakpoints 230 | // in the debugger. 231 | 'no-sequences': 1, 232 | // RATIONALE: Catches code that is likely to be incorrect 233 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 234 | 'no-shadow-restricted-names': 2, 235 | // RATIONALE: Obsolete language feature that is deprecated. 236 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 237 | 'no-sparse-arrays': 2, 238 | // RATIONALE: Although in theory JavaScript allows any possible data type to be thrown as an exception, 239 | // such flexibility adds pointless complexity, by requiring every catch block to test 240 | // the type of the object that it receives. Whereas if catch blocks can always assume 241 | // that their object implements the "Error" contract, then the code is simpler, and 242 | // we generally get useful additional information like a call stack. 243 | 'no-throw-literal': 2, 244 | // RATIONALE: Catches a common coding mistake. 245 | 'no-unmodified-loop-condition': 1, 246 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 247 | 'no-unsafe-finally': 2, 248 | // RATIONALE: Catches a common coding mistake. 249 | 'no-unused-expressions': 1, 250 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 251 | 'no-unused-labels': 1, 252 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 253 | 'no-useless-catch': 1, 254 | // RATIONALE: Avoids a potential performance problem. 255 | 'no-useless-concat': 1, 256 | // RATIONALE: The "var" keyword is deprecated because of its confusing "hoisting" behavior. 257 | // Always use "let" or "const" instead. 258 | // 259 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 260 | 'no-var': 2, 261 | // RATIONALE: Generally not needed in modern code. 262 | 'no-void': 1, 263 | // RATIONALE: Obsolete language feature that is deprecated. 264 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 265 | 'no-with': 2, 266 | // RATIONALE: Makes logic easier to understand, since constants always have a known value 267 | // @typescript-eslint\eslint-plugin\dist\configs\eslint-recommended.js 268 | 'prefer-const': 1, 269 | // RATIONALE: Catches a common coding mistake where "resolve" and "reject" are confused. 270 | 'promise/param-names': 2, 271 | // RATIONALE: Catches code that is likely to be incorrect 272 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 273 | 'require-atomic-updates': 2, 274 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 275 | 'require-yield': 1, 276 | // "Use strict" is redundant when using the TypeScript compiler. 277 | 'strict': [ 278 | 2, 279 | 'never' 280 | ], 281 | // RATIONALE: Catches code that is likely to be incorrect 282 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 283 | 'use-isnan': 2, 284 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 285 | // Set to 1 (warning) or 2 (error) to enable. 286 | // Rationale to disable: !!{} 287 | 'no-extra-boolean-cast': 0, 288 | // ==================================================================== 289 | // @microsoft/eslint-plugin-spfx 290 | // ==================================================================== 291 | '@microsoft/spfx/import-requires-chunk-name': 1, 292 | '@microsoft/spfx/no-require-ensure': 2, 293 | '@microsoft/spfx/pair-react-dom-render-unmount': 1 294 | } 295 | }, 296 | { 297 | // For unit tests, we can be a little bit less strict. The settings below revise the 298 | // defaults specified in the extended configurations, as well as above. 299 | files: [ 300 | // Test files 301 | '*.test.ts', 302 | '*.test.tsx', 303 | '*.spec.ts', 304 | '*.spec.tsx', 305 | 306 | // Facebook convention 307 | '**/__mocks__/*.ts', 308 | '**/__mocks__/*.tsx', 309 | '**/__tests__/*.ts', 310 | '**/__tests__/*.tsx', 311 | 312 | // Microsoft convention 313 | '**/test/*.ts', 314 | '**/test/*.tsx' 315 | ], 316 | rules: {} 317 | } 318 | ] 319 | }; -------------------------------------------------------------------------------- /Demos/01-httpclient/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Dependency directories 7 | node_modules 8 | 9 | # Build generated files 10 | dist 11 | lib 12 | release 13 | solution 14 | temp 15 | *.sppkg 16 | .heft 17 | 18 | # Coverage directory used by tools like istanbul 19 | coverage 20 | 21 | # OSX 22 | .DS_Store 23 | 24 | # Visual Studio files 25 | .ntvs_analysis.dat 26 | .vs 27 | bin 28 | obj 29 | 30 | # Resx Generated Code 31 | *.resx.ts 32 | 33 | # Styles Generated Code 34 | *.scss.ts 35 | -------------------------------------------------------------------------------- /Demos/01-httpclient/.npmignore: -------------------------------------------------------------------------------- 1 | !dist 2 | config 3 | 4 | gulpfile.js 5 | 6 | release 7 | src 8 | temp 9 | 10 | tsconfig.json 11 | tslint.json 12 | 13 | *.log 14 | 15 | .yo-rc.json 16 | .vscode 17 | -------------------------------------------------------------------------------- /Demos/01-httpclient/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Hosted workbench", 6 | "type": "msedge", 7 | "request": "launch", 8 | "url": "https://{tenantDomain}/_layouts/workbench.aspx", 9 | "webRoot": "${workspaceRoot}", 10 | "sourceMaps": true, 11 | "sourceMapPathOverrides": { 12 | "webpack:///.././src/*": "${webRoot}/src/*", 13 | "webpack:///../../../src/*": "${webRoot}/src/*", 14 | "webpack:///../../../../src/*": "${webRoot}/src/*", 15 | "webpack:///../../../../../src/*": "${webRoot}/src/*" 16 | }, 17 | "runtimeArgs": [ 18 | "--remote-debugging-port=9222", 19 | "-incognito" 20 | ] 21 | } 22 | ] 23 | } -------------------------------------------------------------------------------- /Demos/01-httpclient/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | // Configure glob patterns for excluding files and folders in the file explorer. 4 | "files.exclude": { 5 | "**/.git": true, 6 | "**/.DS_Store": true, 7 | "**/bower_components": true, 8 | "**/coverage": true, 9 | "**/jest-output": true, 10 | "**/lib-amd": true, 11 | "src/**/*.scss.ts": true 12 | }, 13 | "typescript.tsdk": ".\\node_modules\\typescript\\lib" 14 | } -------------------------------------------------------------------------------- /Demos/01-httpclient/.yo-rc.json: -------------------------------------------------------------------------------- 1 | { 2 | "@microsoft/generator-sharepoint": { 3 | "plusBeta": false, 4 | "isCreatingSolution": true, 5 | "nodeVersion": "18.20.4", 6 | "sdksVersions": { 7 | "@microsoft/microsoft-graph-client": "3.0.2", 8 | "@microsoft/teams-js": "2.24.0" 9 | }, 10 | "version": "1.20.0", 11 | "libraryName": "sp-fx-http-client", 12 | "libraryId": "c0286e1d-7d5f-431e-b300-54c8370eb9c1", 13 | "environment": "spo", 14 | "packageManager": "npm", 15 | "solutionName": "SPFxHttpClient", 16 | "solutionShortDescription": "SPFxHttpClient description", 17 | "skipFeatureDeployment": true, 18 | "isDomainIsolated": false, 19 | "componentType": "webpart" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Demos/01-httpclient/README.md: -------------------------------------------------------------------------------- 1 | # sp-fx-http-client 2 | 3 | ## Summary 4 | 5 | Short summary on functionality and used technologies. 6 | 7 | [picture of the solution in action, if possible] 8 | 9 | ## Used SharePoint Framework Version 10 | 11 | ![version](https://img.shields.io/badge/version-1.20.0-green.svg) 12 | 13 | ## Applies to 14 | 15 | - [SharePoint Framework](https://aka.ms/spfx) 16 | - [Microsoft 365 tenant](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant) 17 | 18 | > Get your own free development tenant by subscribing to [Microsoft 365 developer program](http://aka.ms/o365devprogram) 19 | 20 | ## Prerequisites 21 | 22 | > Any special pre-requisites? 23 | 24 | ## Solution 25 | 26 | | Solution | Author(s) | 27 | | ----------- | ------------------------------------------------------- | 28 | | folder name | Author details (name, company, twitter alias with link) | 29 | 30 | ## Version history 31 | 32 | | Version | Date | Comments | 33 | | ------- | ---------------- | --------------- | 34 | | 1.1 | March 10, 2021 | Update comment | 35 | | 1.0 | January 29, 2021 | Initial release | 36 | 37 | ## Disclaimer 38 | 39 | **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.** 40 | 41 | --- 42 | 43 | ## Minimal Path to Awesome 44 | 45 | - Clone this repository 46 | - Ensure that you are at the solution folder 47 | - in the command-line run: 48 | - **npm install** 49 | - **gulp serve** 50 | 51 | > Include any additional steps as needed. 52 | 53 | ## Features 54 | 55 | Description of the extension that expands upon high-level summary above. 56 | 57 | This extension illustrates the following concepts: 58 | 59 | - topic 1 60 | - topic 2 61 | - topic 3 62 | 63 | > Notice that better pictures and documentation will increase the sample usage and the value you are providing for others. Thanks for your submissions advance. 64 | 65 | > Share your web part with others through Microsoft 365 Patterns and Practices program to get visibility and exposure. More details on the community, open-source projects and other activities from http://aka.ms/m365pnp. 66 | 67 | ## References 68 | 69 | - [Getting started with SharePoint Framework](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant) 70 | - [Building for Microsoft teams](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/build-for-teams-overview) 71 | - [Use Microsoft Graph in your solution](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/using-microsoft-graph-apis) 72 | - [Publish SharePoint Framework applications to the Marketplace](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/publish-to-marketplace-overview) 73 | - [Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) - Guidance, tooling, samples and open-source controls for your Microsoft 365 development 74 | -------------------------------------------------------------------------------- /Demos/01-httpclient/config/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json", 3 | "version": "2.0", 4 | "bundles": { 5 | "sp-fx-http-client-web-part": { 6 | "components": [ 7 | { 8 | "entrypoint": "./lib/webparts/spFxHttpClient/SpFxHttpClientWebPart.js", 9 | "manifest": "./src/webparts/spFxHttpClient/SpFxHttpClientWebPart.manifest.json" 10 | } 11 | ] 12 | } 13 | }, 14 | "externals": {}, 15 | "localizedResources": { 16 | "SpFxHttpClientWebPartStrings": "lib/webparts/spFxHttpClient/loc/{locale}.js" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Demos/01-httpclient/config/deploy-azure-storage.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json", 3 | "workingDir": "./release/assets/", 4 | "account": "", 5 | "container": "sp-fx-http-client", 6 | "accessKey": "" 7 | } -------------------------------------------------------------------------------- /Demos/01-httpclient/config/package-solution.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json", 3 | "solution": { 4 | "name": "sp-fx-http-client-client-side-solution", 5 | "id": "c0286e1d-7d5f-431e-b300-54c8370eb9c1", 6 | "version": "1.0.0.0", 7 | "includeClientSideAssets": true, 8 | "skipFeatureDeployment": true, 9 | "isDomainIsolated": false, 10 | "developer": { 11 | "name": "", 12 | "websiteUrl": "", 13 | "privacyUrl": "", 14 | "termsOfUseUrl": "", 15 | "mpnId": "Undefined-1.20.0" 16 | }, 17 | "metadata": { 18 | "shortDescription": { 19 | "default": "SPFxHttpClient description" 20 | }, 21 | "longDescription": { 22 | "default": "SPFxHttpClient description" 23 | }, 24 | "screenshotPaths": [], 25 | "videoUrl": "", 26 | "categories": [] 27 | }, 28 | "features": [ 29 | { 30 | "title": "sp-fx-http-client Feature", 31 | "description": "The feature that activates elements of the sp-fx-http-client solution.", 32 | "id": "8a50b44f-137a-435d-bb04-fc6bc8d17aa8", 33 | "version": "1.0.0.0" 34 | } 35 | ] 36 | }, 37 | "paths": { 38 | "zippedPackage": "solution/sp-fx-http-client.sppkg" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Demos/01-httpclient/config/sass.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://developer.microsoft.com/json-schemas/core-build/sass.schema.json" 3 | } -------------------------------------------------------------------------------- /Demos/01-httpclient/config/serve.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/spfx-serve.schema.json", 3 | "port": 4321, 4 | "https": true, 5 | "initialPage": "https://{tenantDomain}/_layouts/workbench.aspx" 6 | } 7 | -------------------------------------------------------------------------------- /Demos/01-httpclient/config/write-manifests.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json", 3 | "cdnBasePath": "" 4 | } -------------------------------------------------------------------------------- /Demos/01-httpclient/gulpfile.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const build = require('@microsoft/sp-build-web'); 4 | 5 | build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`); 6 | 7 | var getTasks = build.rig.getTasks; 8 | build.rig.getTasks = function () { 9 | var result = getTasks.call(build.rig); 10 | 11 | result.set('serve', result.get('serve-deprecated')); 12 | 13 | return result; 14 | }; 15 | 16 | build.initialize(require('gulp')); 17 | -------------------------------------------------------------------------------- /Demos/01-httpclient/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sp-fx-http-client", 3 | "version": "0.0.1", 4 | "private": true, 5 | "engines": { 6 | "node": ">=18.17.1 <19.0.0" 7 | }, 8 | "main": "lib/index.js", 9 | "scripts": { 10 | "build": "gulp bundle", 11 | "clean": "gulp clean", 12 | "test": "gulp test" 13 | }, 14 | "dependencies": { 15 | "tslib": "2.3.1", 16 | "react": "17.0.1", 17 | "react-dom": "17.0.1", 18 | "@fluentui/react": "^8.106.4", 19 | "@microsoft/sp-core-library": "1.20.0", 20 | "@microsoft/sp-component-base": "1.20.0", 21 | "@microsoft/sp-property-pane": "1.20.0", 22 | "@microsoft/sp-webpart-base": "1.20.0", 23 | "@microsoft/sp-lodash-subset": "1.20.0", 24 | "@microsoft/sp-office-ui-fabric-core": "1.20.0" 25 | }, 26 | "devDependencies": { 27 | "@microsoft/rush-stack-compiler-4.7": "0.1.0", 28 | "@rushstack/eslint-config": "4.0.1", 29 | "@microsoft/eslint-plugin-spfx": "1.20.2", 30 | "@microsoft/eslint-config-spfx": "1.20.2", 31 | "@microsoft/sp-build-web": "1.20.2", 32 | "@types/webpack-env": "~1.15.2", 33 | "ajv": "^6.12.5", 34 | "eslint": "8.57.0", 35 | "gulp": "4.0.2", 36 | "typescript": "4.7.4", 37 | "@types/react": "17.0.45", 38 | "@types/react-dom": "17.0.17", 39 | "eslint-plugin-react-hooks": "4.3.0", 40 | "@microsoft/sp-module-interfaces": "1.20.2" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Demos/01-httpclient/src/index.ts: -------------------------------------------------------------------------------- 1 | // A file is required to be in the root of the /src directory by the TypeScript compiler 2 | -------------------------------------------------------------------------------- /Demos/01-httpclient/src/models/INasaImageSearchResponse.ts: -------------------------------------------------------------------------------- 1 | export interface INasaItemData { 2 | title: string; 3 | keywords: string[]; 4 | description: string; 5 | } 6 | 7 | export interface INasaItemLink { 8 | href: string; 9 | } 10 | 11 | export interface INasaItem { 12 | data: INasaItemData[]; 13 | links: INasaItemLink[]; 14 | } 15 | 16 | export interface INasaItemCollection { 17 | items: INasaItem[]; 18 | } 19 | 20 | export interface INasaImageSearchResponse { 21 | collection: INasaItemCollection; 22 | } 23 | -------------------------------------------------------------------------------- /Demos/01-httpclient/src/webparts/spFxHttpClient/SpFxHttpClientWebPart.manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json", 3 | "id": "ff9096ee-7b9d-48ce-bb58-00f807bcc180", 4 | "alias": "SpFxHttpClientWebPart", 5 | "componentType": "WebPart", 6 | 7 | // The "*" signifies that the version should be taken from the package.json 8 | "version": "*", 9 | "manifestVersion": 2, 10 | 11 | // If true, the component can only be installed on sites where Custom Script is allowed. 12 | // Components that allow authors to embed arbitrary script code should set this to true. 13 | // https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f 14 | "requiresCustomScript": false, 15 | "supportedHosts": ["SharePointWebPart", "TeamsPersonalApp", "TeamsTab", "SharePointFullPage"], 16 | "supportsThemeVariants": true, 17 | 18 | "preconfiguredEntries": [{ 19 | "groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Advanced 20 | "group": { "default": "Advanced" }, 21 | "title": { "default": "SPFxHttpClient" }, 22 | "description": { "default": "SPFxHttpClient description" }, 23 | "officeFabricIconFontName": "Page", 24 | "properties": { 25 | "description": "SPFxHttpClient" 26 | } 27 | }] 28 | } 29 | -------------------------------------------------------------------------------- /Demos/01-httpclient/src/webparts/spFxHttpClient/SpFxHttpClientWebPart.ts: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import * as ReactDom from 'react-dom'; 3 | import { Version } from '@microsoft/sp-core-library'; 4 | import { 5 | type IPropertyPaneConfiguration, 6 | PropertyPaneTextField 7 | } from '@microsoft/sp-property-pane'; 8 | import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base'; 9 | import { IReadonlyTheme } from '@microsoft/sp-component-base'; 10 | 11 | import * as strings from 'SpFxHttpClientWebPartStrings'; 12 | import SpFxHttpClient from './components/SpFxHttpClient'; 13 | import { ISpFxHttpClientProps } from './components/ISpFxHttpClientProps'; 14 | 15 | import { 16 | HttpClient, 17 | HttpClientResponse 18 | } from '@microsoft/sp-http'; 19 | 20 | import { INasaImageSearchResponse } from '../../models/INasaImageSearchResponse'; 21 | 22 | export interface ISpFxHttpClientWebPartProps { 23 | description: string; 24 | } 25 | 26 | export default class SpFxHttpClientWebPart extends BaseClientSideWebPart { 27 | 28 | private _isDarkTheme: boolean = false; 29 | private _environmentMessage: string = ''; 30 | 31 | protected get isRenderAsync(): boolean { 32 | return true; 33 | } 34 | 35 | public async render(): Promise { 36 | if (!this.renderedOnce) { 37 | const response: INasaImageSearchResponse = await this._getApolloImage(); 38 | 39 | const element: React.ReactElement = React.createElement( 40 | SpFxHttpClient, 41 | { 42 | apolloMissionImage: response.collection.items[0], 43 | isDarkTheme: this._isDarkTheme, 44 | environmentMessage: this._environmentMessage, 45 | hasTeamsContext: !!this.context.sdks.microsoftTeams, 46 | userDisplayName: this.context.pageContext.user.displayName 47 | } 48 | ); 49 | 50 | ReactDom.render(element, this.domElement); 51 | } 52 | 53 | this.renderCompleted(); 54 | } 55 | 56 | protected renderCompleted(): void { 57 | super.renderCompleted(); 58 | } 59 | 60 | protected onInit(): Promise { 61 | return this._getEnvironmentMessage().then(message => { 62 | this._environmentMessage = message; 63 | }); 64 | } 65 | 66 | private async _getApolloImage(): Promise { 67 | const response: HttpClientResponse = await this.context.httpClient.get( 68 | `https://images-api.nasa.gov/search?q=Apollo%204&media_type=image`, 69 | HttpClient.configurations.v1 70 | ); 71 | 72 | if (!response.ok) { 73 | const responseText = await response.text(); 74 | throw new Error(responseText); 75 | } 76 | 77 | const responseJson = await response.json(); 78 | return responseJson as INasaImageSearchResponse; 79 | } 80 | 81 | private _getEnvironmentMessage(): Promise { 82 | if (!!this.context.sdks.microsoftTeams) { // running in Teams, office.com or Outlook 83 | return this.context.sdks.microsoftTeams.teamsJs.app.getContext() 84 | .then(context => { 85 | let environmentMessage: string = ''; 86 | switch (context.app.host.name) { 87 | case 'Office': // running in Office 88 | environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentOffice : strings.AppOfficeEnvironment; 89 | break; 90 | case 'Outlook': // running in Outlook 91 | environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentOutlook : strings.AppOutlookEnvironment; 92 | break; 93 | case 'Teams': // running in Teams 94 | case 'TeamsModern': 95 | environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentTeams : strings.AppTeamsTabEnvironment; 96 | break; 97 | default: 98 | environmentMessage = strings.UnknownEnvironment; 99 | } 100 | 101 | return environmentMessage; 102 | }); 103 | } 104 | 105 | return Promise.resolve(this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentSharePoint : strings.AppSharePointEnvironment); 106 | } 107 | 108 | protected onThemeChanged(currentTheme: IReadonlyTheme | undefined): void { 109 | if (!currentTheme) { 110 | return; 111 | } 112 | 113 | this._isDarkTheme = !!currentTheme.isInverted; 114 | const { 115 | semanticColors 116 | } = currentTheme; 117 | 118 | if (semanticColors) { 119 | this.domElement.style.setProperty('--bodyText', semanticColors.bodyText || null); 120 | this.domElement.style.setProperty('--link', semanticColors.link || null); 121 | this.domElement.style.setProperty('--linkHovered', semanticColors.linkHovered || null); 122 | } 123 | 124 | } 125 | 126 | protected onDispose(): void { 127 | ReactDom.unmountComponentAtNode(this.domElement); 128 | } 129 | 130 | protected get dataVersion(): Version { 131 | return Version.parse('1.0'); 132 | } 133 | 134 | protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration { 135 | return { 136 | pages: [ 137 | { 138 | header: { 139 | description: strings.PropertyPaneDescription 140 | }, 141 | groups: [ 142 | { 143 | groupName: strings.BasicGroupName, 144 | groupFields: [ 145 | PropertyPaneTextField('description', { 146 | label: strings.DescriptionFieldLabel 147 | }) 148 | ] 149 | } 150 | ] 151 | } 152 | ] 153 | }; 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /Demos/01-httpclient/src/webparts/spFxHttpClient/assets/welcome-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Demos/01-httpclient/src/webparts/spFxHttpClient/assets/welcome-dark.png -------------------------------------------------------------------------------- /Demos/01-httpclient/src/webparts/spFxHttpClient/assets/welcome-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Demos/01-httpclient/src/webparts/spFxHttpClient/assets/welcome-light.png -------------------------------------------------------------------------------- /Demos/01-httpclient/src/webparts/spFxHttpClient/components/ISpFxHttpClientProps.ts: -------------------------------------------------------------------------------- 1 | import { INasaItem } from "../../../models/INasaImageSearchResponse"; 2 | 3 | export interface ISpFxHttpClientProps { 4 | apolloMissionImage: INasaItem; 5 | isDarkTheme: boolean; 6 | environmentMessage: string; 7 | hasTeamsContext: boolean; 8 | userDisplayName: string; 9 | } 10 | -------------------------------------------------------------------------------- /Demos/01-httpclient/src/webparts/spFxHttpClient/components/SpFxHttpClient.module.scss: -------------------------------------------------------------------------------- 1 | @import '~@fluentui/react/dist/sass/References.scss'; 2 | 3 | .spFxHttpClient { 4 | overflow: hidden; 5 | padding: 1em; 6 | color: "[theme:bodyText, default: #323130]"; 7 | color: var(--bodyText); 8 | &.teams { 9 | font-family: $ms-font-family-fallbacks; 10 | } 11 | } 12 | 13 | .welcome { 14 | text-align: center; 15 | } 16 | 17 | .welcomeImage { 18 | width: 100%; 19 | max-width: 420px; 20 | } 21 | 22 | .links { 23 | a { 24 | text-decoration: none; 25 | color: "[theme:link, default:#03787c]"; 26 | color: var(--link); // note: CSS Custom Properties support is limited to modern browsers only 27 | 28 | &:hover { 29 | text-decoration: underline; 30 | color: "[theme:linkHovered, default: #014446]"; 31 | color: var(--linkHovered); // note: CSS Custom Properties support is limited to modern browsers only 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Demos/01-httpclient/src/webparts/spFxHttpClient/components/SpFxHttpClient.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import styles from './SpFxHttpClient.module.scss'; 3 | import type { ISpFxHttpClientProps } from './ISpFxHttpClientProps'; 4 | import { escape } from '@microsoft/sp-lodash-subset'; 5 | 6 | export default class SpFxHttpClient extends React.Component { 7 | public render(): React.ReactElement { 8 | const { 9 | description, 10 | isDarkTheme, 11 | environmentMessage, 12 | hasTeamsContext, 13 | userDisplayName 14 | } = this.props; 15 | 16 | return ( 17 |
18 |
19 | 20 |
Title: {escape(this.props.apolloMissionImage.data[0].title)}
21 |
Keywords:
22 |
    23 | {this.props.apolloMissionImage && 24 | this.props.apolloMissionImage.data[0].keywords.map((keyword: string) => 25 |
  • 26 | {escape(keyword)} 27 |
  • 28 | ) 29 | } 30 |
31 |
32 |
33 | ); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Demos/01-httpclient/src/webparts/spFxHttpClient/loc/en-us.js: -------------------------------------------------------------------------------- 1 | define([], function() { 2 | return { 3 | "PropertyPaneDescription": "Description", 4 | "BasicGroupName": "Group Name", 5 | "DescriptionFieldLabel": "Description Field", 6 | "AppLocalEnvironmentSharePoint": "The app is running on your local environment as SharePoint web part", 7 | "AppLocalEnvironmentTeams": "The app is running on your local environment as Microsoft Teams app", 8 | "AppLocalEnvironmentOffice": "The app is running on your local environment in office.com", 9 | "AppLocalEnvironmentOutlook": "The app is running on your local environment in Outlook", 10 | "AppSharePointEnvironment": "The app is running on SharePoint page", 11 | "AppTeamsTabEnvironment": "The app is running in Microsoft Teams", 12 | "AppOfficeEnvironment": "The app is running in office.com", 13 | "AppOutlookEnvironment": "The app is running in Outlook", 14 | "UnknownEnvironment": "The app is running in an unknown environment" 15 | } 16 | }); -------------------------------------------------------------------------------- /Demos/01-httpclient/src/webparts/spFxHttpClient/loc/mystrings.d.ts: -------------------------------------------------------------------------------- 1 | declare interface ISpFxHttpClientWebPartStrings { 2 | PropertyPaneDescription: string; 3 | BasicGroupName: string; 4 | DescriptionFieldLabel: string; 5 | AppLocalEnvironmentSharePoint: string; 6 | AppLocalEnvironmentTeams: string; 7 | AppLocalEnvironmentOffice: string; 8 | AppLocalEnvironmentOutlook: string; 9 | AppSharePointEnvironment: string; 10 | AppTeamsTabEnvironment: string; 11 | AppOfficeEnvironment: string; 12 | AppOutlookEnvironment: string; 13 | UnknownEnvironment: string; 14 | } 15 | 16 | declare module 'SpFxHttpClientWebPartStrings' { 17 | const strings: ISpFxHttpClientWebPartStrings; 18 | export = strings; 19 | } 20 | -------------------------------------------------------------------------------- /Demos/01-httpclient/teams/ff9096ee-7b9d-48ce-bb58-00f807bcc180_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Demos/01-httpclient/teams/ff9096ee-7b9d-48ce-bb58-00f807bcc180_color.png -------------------------------------------------------------------------------- /Demos/01-httpclient/teams/ff9096ee-7b9d-48ce-bb58-00f807bcc180_outline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Demos/01-httpclient/teams/ff9096ee-7b9d-48ce-bb58-00f807bcc180_outline.png -------------------------------------------------------------------------------- /Demos/01-httpclient/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./node_modules/@microsoft/rush-stack-compiler-4.7/includes/tsconfig-web.json", 3 | "compilerOptions": { 4 | "target": "es5", 5 | "forceConsistentCasingInFileNames": true, 6 | "module": "esnext", 7 | "moduleResolution": "node", 8 | "jsx": "react", 9 | "declaration": true, 10 | "sourceMap": true, 11 | "experimentalDecorators": true, 12 | "skipLibCheck": true, 13 | "outDir": "lib", 14 | "inlineSources": false, 15 | "noImplicitAny": true, 16 | 17 | "typeRoots": [ 18 | "./node_modules/@types", 19 | "./node_modules/@microsoft" 20 | ], 21 | "types": [ 22 | "webpack-env" 23 | ], 24 | "lib": [ 25 | "es5", 26 | "dom", 27 | "es2015.collection", 28 | "es2015.promise" 29 | ] 30 | }, 31 | "include": [ 32 | "src/**/*.ts", 33 | "src/**/*.tsx" 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/.eslintrc.js: -------------------------------------------------------------------------------- 1 | require('@rushstack/eslint-config/patch/modern-module-resolution'); 2 | module.exports = { 3 | extends: ['@microsoft/eslint-config-spfx/lib/profiles/react'], 4 | parserOptions: { tsconfigRootDir: __dirname }, 5 | overrides: [ 6 | { 7 | files: ['*.ts', '*.tsx'], 8 | parser: '@typescript-eslint/parser', 9 | 'parserOptions': { 10 | 'project': './tsconfig.json', 11 | 'ecmaVersion': 2018, 12 | 'sourceType': 'module' 13 | }, 14 | rules: { 15 | // Prevent usage of the JavaScript null value, while allowing code to access existing APIs that may require null. https://www.npmjs.com/package/@rushstack/eslint-plugin 16 | '@rushstack/no-new-null': 1, 17 | // Require Jest module mocking APIs to be called before any other statements in their code block. https://www.npmjs.com/package/@rushstack/eslint-plugin 18 | '@rushstack/hoist-jest-mock': 1, 19 | // Require regular expressions to be constructed from string constants rather than dynamically building strings at runtime. https://www.npmjs.com/package/@rushstack/eslint-plugin-security 20 | '@rushstack/security/no-unsafe-regexp': 1, 21 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 22 | '@typescript-eslint/adjacent-overload-signatures': 1, 23 | // RATIONALE: Code is more readable when the type of every variable is immediately obvious. 24 | // Even if the compiler may be able to infer a type, this inference will be unavailable 25 | // to a person who is reviewing a GitHub diff. This rule makes writing code harder, 26 | // but writing code is a much less important activity than reading it. 27 | // 28 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 29 | '@typescript-eslint/explicit-function-return-type': [ 30 | 1, 31 | { 32 | 'allowExpressions': true, 33 | 'allowTypedFunctionExpressions': true, 34 | 'allowHigherOrderFunctions': false 35 | } 36 | ], 37 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 38 | // Rationale to disable: although this is a recommended rule, it is up to dev to select coding style. 39 | // Set to 1 (warning) or 2 (error) to enable. 40 | '@typescript-eslint/explicit-member-accessibility': 0, 41 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 42 | '@typescript-eslint/no-array-constructor': 1, 43 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 44 | // 45 | // RATIONALE: The "any" keyword disables static type checking, the main benefit of using TypeScript. 46 | // This rule should be suppressed only in very special cases such as JSON.stringify() 47 | // where the type really can be anything. Even if the type is flexible, another type 48 | // may be more appropriate such as "unknown", "{}", or "Record". 49 | '@typescript-eslint/no-explicit-any': 1, 50 | // RATIONALE: The #1 rule of promises is that every promise chain must be terminated by a catch() 51 | // handler. Thus wherever a Promise arises, the code must either append a catch handler, 52 | // or else return the object to a caller (who assumes this responsibility). Unterminated 53 | // promise chains are a serious issue. Besides causing errors to be silently ignored, 54 | // they can also cause a NodeJS process to terminate unexpectedly. 55 | '@typescript-eslint/no-floating-promises': 2, 56 | // RATIONALE: Catches a common coding mistake. 57 | '@typescript-eslint/no-for-in-array': 2, 58 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 59 | '@typescript-eslint/no-misused-new': 2, 60 | // RATIONALE: The "namespace" keyword is not recommended for organizing code because JavaScript lacks 61 | // a "using" statement to traverse namespaces. Nested namespaces prevent certain bundler 62 | // optimizations. If you are declaring loose functions/variables, it's better to make them 63 | // static members of a class, since classes support property getters and their private 64 | // members are accessible by unit tests. Also, the exercise of choosing a meaningful 65 | // class name tends to produce more discoverable APIs: for example, search+replacing 66 | // the function "reverse()" is likely to return many false matches, whereas if we always 67 | // write "Text.reverse()" is more unique. For large scale organization, it's recommended 68 | // to decompose your code into separate NPM packages, which ensures that component 69 | // dependencies are tracked more conscientiously. 70 | // 71 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 72 | '@typescript-eslint/no-namespace': [ 73 | 1, 74 | { 75 | 'allowDeclarations': false, 76 | 'allowDefinitionFiles': false 77 | } 78 | ], 79 | // RATIONALE: Parameter properties provide a shorthand such as "constructor(public title: string)" 80 | // that avoids the effort of declaring "title" as a field. This TypeScript feature makes 81 | // code easier to write, but arguably sacrifices readability: In the notes for 82 | // "@typescript-eslint/member-ordering" we pointed out that fields are central to 83 | // a class's design, so we wouldn't want to bury them in a constructor signature 84 | // just to save some typing. 85 | // 86 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 87 | // Set to 1 (warning) or 2 (error) to enable the rule 88 | '@typescript-eslint/parameter-properties': 0, 89 | // RATIONALE: When left in shipping code, unused variables often indicate a mistake. Dead code 90 | // may impact performance. 91 | // 92 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 93 | '@typescript-eslint/no-unused-vars': [ 94 | 1, 95 | { 96 | 'vars': 'all', 97 | // Unused function arguments often indicate a mistake in JavaScript code. However in TypeScript code, 98 | // the compiler catches most of those mistakes, and unused arguments are fairly common for type signatures 99 | // that are overriding a base class method or implementing an interface. 100 | 'args': 'none' 101 | } 102 | ], 103 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 104 | '@typescript-eslint/no-use-before-define': [ 105 | 2, 106 | { 107 | 'functions': false, 108 | 'classes': true, 109 | 'variables': true, 110 | 'enums': true, 111 | 'typedefs': true 112 | } 113 | ], 114 | // Disallows require statements except in import statements. 115 | // In other words, the use of forms such as var foo = require("foo") are banned. Instead use ES6 style imports or import foo = require("foo") imports. 116 | '@typescript-eslint/no-var-requires': 'error', 117 | // RATIONALE: The "module" keyword is deprecated except when describing legacy libraries. 118 | // 119 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 120 | '@typescript-eslint/prefer-namespace-keyword': 1, 121 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 122 | // Rationale to disable: it's up to developer to decide if he wants to add type annotations 123 | // Set to 1 (warning) or 2 (error) to enable the rule 124 | '@typescript-eslint/no-inferrable-types': 0, 125 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 126 | // Rationale to disable: declaration of empty interfaces may be helpful for generic types scenarios 127 | '@typescript-eslint/no-empty-interface': 0, 128 | // RATIONALE: This rule warns if setters are defined without getters, which is probably a mistake. 129 | 'accessor-pairs': 1, 130 | // RATIONALE: In TypeScript, if you write x["y"] instead of x.y, it disables type checking. 131 | 'dot-notation': [ 132 | 1, 133 | { 134 | 'allowPattern': '^_' 135 | } 136 | ], 137 | // RATIONALE: Catches code that is likely to be incorrect 138 | 'eqeqeq': 1, 139 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 140 | 'for-direction': 1, 141 | // RATIONALE: Catches a common coding mistake. 142 | 'guard-for-in': 2, 143 | // RATIONALE: If you have more than 2,000 lines in a single source file, it's probably time 144 | // to split up your code. 145 | 'max-lines': ['warn', { max: 2000 }], 146 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 147 | 'no-async-promise-executor': 2, 148 | // RATIONALE: Deprecated language feature. 149 | 'no-caller': 2, 150 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 151 | 'no-compare-neg-zero': 2, 152 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 153 | 'no-cond-assign': 2, 154 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 155 | 'no-constant-condition': 1, 156 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 157 | 'no-control-regex': 2, 158 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 159 | 'no-debugger': 1, 160 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 161 | 'no-delete-var': 2, 162 | // RATIONALE: Catches code that is likely to be incorrect 163 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 164 | 'no-duplicate-case': 2, 165 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 166 | 'no-empty': 1, 167 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 168 | 'no-empty-character-class': 2, 169 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 170 | 'no-empty-pattern': 1, 171 | // RATIONALE: Eval is a security concern and a performance concern. 172 | 'no-eval': 1, 173 | // RATIONALE: Catches code that is likely to be incorrect 174 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 175 | 'no-ex-assign': 2, 176 | // RATIONALE: System types are global and should not be tampered with in a scalable code base. 177 | // If two different libraries (or two versions of the same library) both try to modify 178 | // a type, only one of them can win. Polyfills are acceptable because they implement 179 | // a standardized interoperable contract, but polyfills are generally coded in plain 180 | // JavaScript. 181 | 'no-extend-native': 1, 182 | // Disallow unnecessary labels 183 | 'no-extra-label': 1, 184 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 185 | 'no-fallthrough': 2, 186 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 187 | 'no-func-assign': 1, 188 | // RATIONALE: Catches a common coding mistake. 189 | 'no-implied-eval': 2, 190 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 191 | 'no-invalid-regexp': 2, 192 | // RATIONALE: Catches a common coding mistake. 193 | 'no-label-var': 2, 194 | // RATIONALE: Eliminates redundant code. 195 | 'no-lone-blocks': 1, 196 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 197 | 'no-misleading-character-class': 2, 198 | // RATIONALE: Catches a common coding mistake. 199 | 'no-multi-str': 2, 200 | // RATIONALE: It's generally a bad practice to call "new Thing()" without assigning the result to 201 | // a variable. Either it's part of an awkward expression like "(new Thing()).doSomething()", 202 | // or else implies that the constructor is doing nontrivial computations, which is often 203 | // a poor class design. 204 | 'no-new': 1, 205 | // RATIONALE: Obsolete language feature that is deprecated. 206 | 'no-new-func': 2, 207 | // RATIONALE: Obsolete language feature that is deprecated. 208 | 'no-new-object': 2, 209 | // RATIONALE: Obsolete notation. 210 | 'no-new-wrappers': 1, 211 | // RATIONALE: Catches code that is likely to be incorrect 212 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 213 | 'no-octal': 2, 214 | // RATIONALE: Catches code that is likely to be incorrect 215 | 'no-octal-escape': 2, 216 | // RATIONALE: Catches code that is likely to be incorrect 217 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 218 | 'no-regex-spaces': 2, 219 | // RATIONALE: Catches a common coding mistake. 220 | 'no-return-assign': 2, 221 | // RATIONALE: Security risk. 222 | 'no-script-url': 1, 223 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 224 | 'no-self-assign': 2, 225 | // RATIONALE: Catches a common coding mistake. 226 | 'no-self-compare': 2, 227 | // RATIONALE: This avoids statements such as "while (a = next(), a && a.length);" that use 228 | // commas to create compound expressions. In general code is more readable if each 229 | // step is split onto a separate line. This also makes it easier to set breakpoints 230 | // in the debugger. 231 | 'no-sequences': 1, 232 | // RATIONALE: Catches code that is likely to be incorrect 233 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 234 | 'no-shadow-restricted-names': 2, 235 | // RATIONALE: Obsolete language feature that is deprecated. 236 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 237 | 'no-sparse-arrays': 2, 238 | // RATIONALE: Although in theory JavaScript allows any possible data type to be thrown as an exception, 239 | // such flexibility adds pointless complexity, by requiring every catch block to test 240 | // the type of the object that it receives. Whereas if catch blocks can always assume 241 | // that their object implements the "Error" contract, then the code is simpler, and 242 | // we generally get useful additional information like a call stack. 243 | 'no-throw-literal': 2, 244 | // RATIONALE: Catches a common coding mistake. 245 | 'no-unmodified-loop-condition': 1, 246 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 247 | 'no-unsafe-finally': 2, 248 | // RATIONALE: Catches a common coding mistake. 249 | 'no-unused-expressions': 1, 250 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 251 | 'no-unused-labels': 1, 252 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 253 | 'no-useless-catch': 1, 254 | // RATIONALE: Avoids a potential performance problem. 255 | 'no-useless-concat': 1, 256 | // RATIONALE: The "var" keyword is deprecated because of its confusing "hoisting" behavior. 257 | // Always use "let" or "const" instead. 258 | // 259 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 260 | 'no-var': 2, 261 | // RATIONALE: Generally not needed in modern code. 262 | 'no-void': 1, 263 | // RATIONALE: Obsolete language feature that is deprecated. 264 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 265 | 'no-with': 2, 266 | // RATIONALE: Makes logic easier to understand, since constants always have a known value 267 | // @typescript-eslint\eslint-plugin\dist\configs\eslint-recommended.js 268 | 'prefer-const': 1, 269 | // RATIONALE: Catches a common coding mistake where "resolve" and "reject" are confused. 270 | 'promise/param-names': 2, 271 | // RATIONALE: Catches code that is likely to be incorrect 272 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 273 | 'require-atomic-updates': 2, 274 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 275 | 'require-yield': 1, 276 | // "Use strict" is redundant when using the TypeScript compiler. 277 | 'strict': [ 278 | 2, 279 | 'never' 280 | ], 281 | // RATIONALE: Catches code that is likely to be incorrect 282 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 283 | 'use-isnan': 2, 284 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 285 | // Set to 1 (warning) or 2 (error) to enable. 286 | // Rationale to disable: !!{} 287 | 'no-extra-boolean-cast': 0, 288 | // ==================================================================== 289 | // @microsoft/eslint-plugin-spfx 290 | // ==================================================================== 291 | '@microsoft/spfx/import-requires-chunk-name': 1, 292 | '@microsoft/spfx/no-require-ensure': 2, 293 | '@microsoft/spfx/pair-react-dom-render-unmount': 1 294 | } 295 | }, 296 | { 297 | // For unit tests, we can be a little bit less strict. The settings below revise the 298 | // defaults specified in the extended configurations, as well as above. 299 | files: [ 300 | // Test files 301 | '*.test.ts', 302 | '*.test.tsx', 303 | '*.spec.ts', 304 | '*.spec.tsx', 305 | 306 | // Facebook convention 307 | '**/__mocks__/*.ts', 308 | '**/__mocks__/*.tsx', 309 | '**/__tests__/*.ts', 310 | '**/__tests__/*.tsx', 311 | 312 | // Microsoft convention 313 | '**/test/*.ts', 314 | '**/test/*.tsx' 315 | ], 316 | rules: {} 317 | } 318 | ] 319 | }; -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Dependency directories 7 | node_modules 8 | 9 | # Build generated files 10 | dist 11 | lib 12 | release 13 | solution 14 | temp 15 | *.sppkg 16 | .heft 17 | 18 | # Coverage directory used by tools like istanbul 19 | coverage 20 | 21 | # OSX 22 | .DS_Store 23 | 24 | # Visual Studio files 25 | .ntvs_analysis.dat 26 | .vs 27 | bin 28 | obj 29 | 30 | # Resx Generated Code 31 | *.resx.ts 32 | 33 | # Styles Generated Code 34 | *.scss.ts 35 | -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/.npmignore: -------------------------------------------------------------------------------- 1 | !dist 2 | config 3 | 4 | gulpfile.js 5 | 6 | release 7 | src 8 | temp 9 | 10 | tsconfig.json 11 | tslint.json 12 | 13 | *.log 14 | 15 | .yo-rc.json 16 | .vscode 17 | -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Hosted workbench", 6 | "type": "msedge", 7 | "request": "launch", 8 | "url": "https://{tenantDomain}/_layouts/workbench.aspx", 9 | "webRoot": "${workspaceRoot}", 10 | "sourceMaps": true, 11 | "sourceMapPathOverrides": { 12 | "webpack:///.././src/*": "${webRoot}/src/*", 13 | "webpack:///../../../src/*": "${webRoot}/src/*", 14 | "webpack:///../../../../src/*": "${webRoot}/src/*", 15 | "webpack:///../../../../../src/*": "${webRoot}/src/*" 16 | }, 17 | "runtimeArgs": [ 18 | "--remote-debugging-port=9222", 19 | "-incognito" 20 | ] 21 | } 22 | ] 23 | } -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | // Configure glob patterns for excluding files and folders in the file explorer. 4 | "files.exclude": { 5 | "**/.git": true, 6 | "**/.DS_Store": true, 7 | "**/bower_components": true, 8 | "**/coverage": true, 9 | "**/jest-output": true, 10 | "**/lib-amd": true, 11 | "src/**/*.scss.ts": true 12 | }, 13 | "typescript.tsdk": ".\\node_modules\\typescript\\lib" 14 | } -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/.yo-rc.json: -------------------------------------------------------------------------------- 1 | { 2 | "@microsoft/generator-sharepoint": { 3 | "plusBeta": false, 4 | "isCreatingSolution": true, 5 | "nodeVersion": "18.20.4", 6 | "sdksVersions": { 7 | "@microsoft/microsoft-graph-client": "3.0.2", 8 | "@microsoft/teams-js": "2.24.0" 9 | }, 10 | "version": "1.20.0", 11 | "libraryName": "sp-fx-aad-http-client", 12 | "libraryId": "66e35303-bdc5-4d83-8b63-16ba8c59c649", 13 | "environment": "spo", 14 | "packageManager": "npm", 15 | "solutionName": "SPFxAadHttpClient", 16 | "solutionShortDescription": "SPFxAadHttpClient description", 17 | "skipFeatureDeployment": true, 18 | "isDomainIsolated": false, 19 | "componentType": "webpart" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/README.md: -------------------------------------------------------------------------------- 1 | # sp-fx-aad-http-client 2 | 3 | ## Summary 4 | 5 | Short summary on functionality and used technologies. 6 | 7 | [picture of the solution in action, if possible] 8 | 9 | ## Used SharePoint Framework Version 10 | 11 | ![version](https://img.shields.io/badge/version-1.20.0-green.svg) 12 | 13 | ## Applies to 14 | 15 | - [SharePoint Framework](https://aka.ms/spfx) 16 | - [Microsoft 365 tenant](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant) 17 | 18 | > Get your own free development tenant by subscribing to [Microsoft 365 developer program](http://aka.ms/o365devprogram) 19 | 20 | ## Prerequisites 21 | 22 | > Any special pre-requisites? 23 | 24 | ## Solution 25 | 26 | | Solution | Author(s) | 27 | | ----------- | ------------------------------------------------------- | 28 | | folder name | Author details (name, company, twitter alias with link) | 29 | 30 | ## Version history 31 | 32 | | Version | Date | Comments | 33 | | ------- | ---------------- | --------------- | 34 | | 1.1 | March 10, 2021 | Update comment | 35 | | 1.0 | January 29, 2021 | Initial release | 36 | 37 | ## Disclaimer 38 | 39 | **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.** 40 | 41 | --- 42 | 43 | ## Minimal Path to Awesome 44 | 45 | - Clone this repository 46 | - Ensure that you are at the solution folder 47 | - in the command-line run: 48 | - **npm install** 49 | - **gulp serve** 50 | 51 | > Include any additional steps as needed. 52 | 53 | ## Features 54 | 55 | Description of the extension that expands upon high-level summary above. 56 | 57 | This extension illustrates the following concepts: 58 | 59 | - topic 1 60 | - topic 2 61 | - topic 3 62 | 63 | > Notice that better pictures and documentation will increase the sample usage and the value you are providing for others. Thanks for your submissions advance. 64 | 65 | > Share your web part with others through Microsoft 365 Patterns and Practices program to get visibility and exposure. More details on the community, open-source projects and other activities from http://aka.ms/m365pnp. 66 | 67 | ## References 68 | 69 | - [Getting started with SharePoint Framework](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant) 70 | - [Building for Microsoft teams](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/build-for-teams-overview) 71 | - [Use Microsoft Graph in your solution](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/using-microsoft-graph-apis) 72 | - [Publish SharePoint Framework applications to the Marketplace](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/publish-to-marketplace-overview) 73 | - [Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) - Guidance, tooling, samples and open-source controls for your Microsoft 365 development 74 | -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/config/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json", 3 | "version": "2.0", 4 | "bundles": { 5 | "sp-fx-aad-http-client-web-part": { 6 | "components": [ 7 | { 8 | "entrypoint": "./lib/webparts/spFxAadHttpClient/SpFxAadHttpClientWebPart.js", 9 | "manifest": "./src/webparts/spFxAadHttpClient/SpFxAadHttpClientWebPart.manifest.json" 10 | } 11 | ] 12 | } 13 | }, 14 | "externals": {}, 15 | "localizedResources": { 16 | "SpFxAadHttpClientWebPartStrings": "lib/webparts/spFxAadHttpClient/loc/{locale}.js" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/config/deploy-azure-storage.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json", 3 | "workingDir": "./release/assets/", 4 | "account": "", 5 | "container": "sp-fx-aad-http-client", 6 | "accessKey": "" 7 | } -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/config/package-solution.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json", 3 | "solution": { 4 | "name": "sp-fx-aad-http-client-client-side-solution", 5 | "id": "66e35303-bdc5-4d83-8b63-16ba8c59c649", 6 | "version": "1.0.0.0", 7 | "includeClientSideAssets": true, 8 | "skipFeatureDeployment": true, 9 | "isDomainIsolated": false, 10 | "webApiPermissionRequests": [ 11 | { 12 | "resource": "Microsoft Graph", 13 | "scope": "User.ReadBasic.All" 14 | } 15 | ], 16 | "developer": { 17 | "name": "", 18 | "websiteUrl": "", 19 | "privacyUrl": "", 20 | "termsOfUseUrl": "", 21 | "mpnId": "Undefined-1.20.0" 22 | }, 23 | "metadata": { 24 | "shortDescription": { 25 | "default": "SPFxAadHttpClient description" 26 | }, 27 | "longDescription": { 28 | "default": "SPFxAadHttpClient description" 29 | }, 30 | "screenshotPaths": [], 31 | "videoUrl": "", 32 | "categories": [] 33 | }, 34 | "features": [ 35 | { 36 | "title": "sp-fx-aad-http-client Feature", 37 | "description": "The feature that activates elements of the sp-fx-aad-http-client solution.", 38 | "id": "77b0555d-d90d-4fbe-8d0f-96235977ef60", 39 | "version": "1.0.0.0" 40 | } 41 | ] 42 | }, 43 | "paths": { 44 | "zippedPackage": "solution/sp-fx-aad-http-client.sppkg" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/config/sass.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://developer.microsoft.com/json-schemas/core-build/sass.schema.json" 3 | } -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/config/serve.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/spfx-serve.schema.json", 3 | "port": 4321, 4 | "https": true, 5 | "initialPage": "https://{tenantDomain}/_layouts/workbench.aspx" 6 | } 7 | -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/config/write-manifests.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json", 3 | "cdnBasePath": "" 4 | } -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/gulpfile.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const build = require('@microsoft/sp-build-web'); 4 | 5 | build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`); 6 | 7 | var getTasks = build.rig.getTasks; 8 | build.rig.getTasks = function () { 9 | var result = getTasks.call(build.rig); 10 | 11 | result.set('serve', result.get('serve-deprecated')); 12 | 13 | return result; 14 | }; 15 | 16 | build.initialize(require('gulp')); 17 | -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sp-fx-aad-http-client", 3 | "version": "0.0.1", 4 | "private": true, 5 | "engines": { 6 | "node": ">=18.17.1 <19.0.0" 7 | }, 8 | "main": "lib/index.js", 9 | "scripts": { 10 | "build": "gulp bundle", 11 | "clean": "gulp clean", 12 | "test": "gulp test" 13 | }, 14 | "dependencies": { 15 | "tslib": "2.3.1", 16 | "react": "17.0.1", 17 | "react-dom": "17.0.1", 18 | "@fluentui/react": "^8.106.4", 19 | "@microsoft/sp-core-library": "1.20.0", 20 | "@microsoft/sp-component-base": "1.20.0", 21 | "@microsoft/sp-property-pane": "1.20.0", 22 | "@microsoft/sp-webpart-base": "1.20.0", 23 | "@microsoft/sp-lodash-subset": "1.20.0", 24 | "@microsoft/sp-office-ui-fabric-core": "1.20.0" 25 | }, 26 | "devDependencies": { 27 | "@microsoft/rush-stack-compiler-4.7": "0.1.0", 28 | "@rushstack/eslint-config": "4.0.1", 29 | "@microsoft/eslint-plugin-spfx": "1.20.2", 30 | "@microsoft/eslint-config-spfx": "1.20.2", 31 | "@microsoft/sp-build-web": "1.20.2", 32 | "@types/webpack-env": "~1.15.2", 33 | "ajv": "^6.12.5", 34 | "eslint": "8.57.0", 35 | "gulp": "4.0.2", 36 | "typescript": "4.7.4", 37 | "@types/react": "17.0.45", 38 | "@types/react-dom": "17.0.17", 39 | "eslint-plugin-react-hooks": "4.3.0", 40 | "@microsoft/sp-module-interfaces": "1.20.2" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/src/index.ts: -------------------------------------------------------------------------------- 1 | // A file is required to be in the root of the /src directory by the TypeScript compiler 2 | -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/src/models/IUserItem.ts: -------------------------------------------------------------------------------- 1 | export interface IUserItem { 2 | id: string; 3 | mail?: string; 4 | displayName?: string; 5 | } 6 | -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/src/webparts/spFxAadHttpClient/SpFxAadHttpClientWebPart.manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json", 3 | "id": "b37c4dcf-3f2d-4539-a2cd-9afa00e818a5", 4 | "alias": "SpFxAadHttpClientWebPart", 5 | "componentType": "WebPart", 6 | 7 | // The "*" signifies that the version should be taken from the package.json 8 | "version": "*", 9 | "manifestVersion": 2, 10 | 11 | // If true, the component can only be installed on sites where Custom Script is allowed. 12 | // Components that allow authors to embed arbitrary script code should set this to true. 13 | // https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f 14 | "requiresCustomScript": false, 15 | "supportedHosts": ["SharePointWebPart", "TeamsPersonalApp", "TeamsTab", "SharePointFullPage"], 16 | "supportsThemeVariants": true, 17 | 18 | "preconfiguredEntries": [{ 19 | "groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Advanced 20 | "group": { "default": "Advanced" }, 21 | "title": { "default": "SPFxAadHttpClient" }, 22 | "description": { "default": "SPFxAadHttpClient description" }, 23 | "officeFabricIconFontName": "Page", 24 | "properties": { 25 | "description": "SPFxAadHttpClient" 26 | } 27 | }] 28 | } 29 | -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/src/webparts/spFxAadHttpClient/SpFxAadHttpClientWebPart.ts: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import * as ReactDom from 'react-dom'; 3 | import { Version } from '@microsoft/sp-core-library'; 4 | import { 5 | type IPropertyPaneConfiguration, 6 | PropertyPaneTextField 7 | } from '@microsoft/sp-property-pane'; 8 | import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base'; 9 | import { IReadonlyTheme } from '@microsoft/sp-component-base'; 10 | 11 | import * as strings from 'SpFxAadHttpClientWebPartStrings'; 12 | import SpFxAadHttpClient from './components/SpFxAadHttpClient'; 13 | import { ISpFxAadHttpClientProps } from './components/ISpFxAadHttpClientProps'; 14 | 15 | import { IUserItem } from '../../models/IUserItem'; 16 | import { 17 | AadHttpClient, 18 | HttpClientResponse 19 | } from '@microsoft/sp-http'; 20 | 21 | export interface ISpFxAadHttpClientWebPartProps { 22 | description: string; 23 | } 24 | 25 | export default class SpFxAadHttpClientWebPart extends BaseClientSideWebPart { 26 | 27 | private _isDarkTheme: boolean = false; 28 | private _environmentMessage: string = ''; 29 | 30 | protected get isRenderAsync(): boolean { 31 | return true; 32 | } 33 | 34 | public async render(): Promise { 35 | if (!this.renderedOnce) { 36 | const results: IUserItem[] = await this._getUsers(); 37 | 38 | const element: React.ReactElement = React.createElement( 39 | SpFxAadHttpClient, 40 | { 41 | userItems: results, 42 | isDarkTheme: this._isDarkTheme, 43 | environmentMessage: this._environmentMessage, 44 | hasTeamsContext: !!this.context.sdks.microsoftTeams, 45 | userDisplayName: this.context.pageContext.user.displayName 46 | } 47 | ); 48 | 49 | ReactDom.render(element, this.domElement); 50 | } 51 | 52 | this.renderCompleted(); 53 | } 54 | 55 | protected renderCompleted(): void { 56 | super.renderCompleted(); 57 | } 58 | 59 | protected onInit(): Promise { 60 | return this._getEnvironmentMessage().then(message => { 61 | this._environmentMessage = message; 62 | }); 63 | } 64 | 65 | private async _getUsers(): Promise { 66 | const aadClient: AadHttpClient = await this.context.aadHttpClientFactory 67 | .getClient('https://graph.microsoft.com'); 68 | 69 | const endpoint: string = 'https://graph.microsoft.com/v1.0/users?$top=10&$select=id,displayName,mail'; 70 | const response: HttpClientResponse = await aadClient.get(endpoint, AadHttpClient.configurations.v1); 71 | 72 | if (!response.ok) { 73 | const responseText = await response.text(); 74 | throw new Error(responseText); 75 | } 76 | 77 | const responseJson = await response.json(); 78 | return responseJson.value as IUserItem[]; 79 | } 80 | 81 | private _getEnvironmentMessage(): Promise { 82 | if (!!this.context.sdks.microsoftTeams) { // running in Teams, office.com or Outlook 83 | return this.context.sdks.microsoftTeams.teamsJs.app.getContext() 84 | .then(context => { 85 | let environmentMessage: string = ''; 86 | switch (context.app.host.name) { 87 | case 'Office': // running in Office 88 | environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentOffice : strings.AppOfficeEnvironment; 89 | break; 90 | case 'Outlook': // running in Outlook 91 | environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentOutlook : strings.AppOutlookEnvironment; 92 | break; 93 | case 'Teams': // running in Teams 94 | case 'TeamsModern': 95 | environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentTeams : strings.AppTeamsTabEnvironment; 96 | break; 97 | default: 98 | environmentMessage = strings.UnknownEnvironment; 99 | } 100 | 101 | return environmentMessage; 102 | }); 103 | } 104 | 105 | return Promise.resolve(this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentSharePoint : strings.AppSharePointEnvironment); 106 | } 107 | 108 | protected onThemeChanged(currentTheme: IReadonlyTheme | undefined): void { 109 | if (!currentTheme) { 110 | return; 111 | } 112 | 113 | this._isDarkTheme = !!currentTheme.isInverted; 114 | const { 115 | semanticColors 116 | } = currentTheme; 117 | 118 | if (semanticColors) { 119 | this.domElement.style.setProperty('--bodyText', semanticColors.bodyText || null); 120 | this.domElement.style.setProperty('--link', semanticColors.link || null); 121 | this.domElement.style.setProperty('--linkHovered', semanticColors.linkHovered || null); 122 | } 123 | 124 | } 125 | 126 | protected onDispose(): void { 127 | ReactDom.unmountComponentAtNode(this.domElement); 128 | } 129 | 130 | protected get dataVersion(): Version { 131 | return Version.parse('1.0'); 132 | } 133 | 134 | protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration { 135 | return { 136 | pages: [ 137 | { 138 | header: { 139 | description: strings.PropertyPaneDescription 140 | }, 141 | groups: [ 142 | { 143 | groupName: strings.BasicGroupName, 144 | groupFields: [ 145 | PropertyPaneTextField('description', { 146 | label: strings.DescriptionFieldLabel 147 | }) 148 | ] 149 | } 150 | ] 151 | } 152 | ] 153 | }; 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/src/webparts/spFxAadHttpClient/assets/welcome-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Demos/02-aadhttpclient/src/webparts/spFxAadHttpClient/assets/welcome-dark.png -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/src/webparts/spFxAadHttpClient/assets/welcome-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Demos/02-aadhttpclient/src/webparts/spFxAadHttpClient/assets/welcome-light.png -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/src/webparts/spFxAadHttpClient/components/ISpFxAadHttpClientProps.ts: -------------------------------------------------------------------------------- 1 | import { IUserItem } from '../../../models/IUserItem'; 2 | 3 | export interface ISpFxAadHttpClientProps { 4 | userItems: IUserItem[]; 5 | isDarkTheme: boolean; 6 | environmentMessage: string; 7 | hasTeamsContext: boolean; 8 | userDisplayName: string; 9 | } 10 | -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/src/webparts/spFxAadHttpClient/components/SpFxAadHttpClient.module.scss: -------------------------------------------------------------------------------- 1 | @import '~@fluentui/react/dist/sass/References.scss'; 2 | 3 | .spFxAadHttpClient { 4 | overflow: hidden; 5 | padding: 1em; 6 | color: "[theme:bodyText, default: #323130]"; 7 | color: var(--bodyText); 8 | &.teams { 9 | font-family: $ms-font-family-fallbacks; 10 | } 11 | } 12 | 13 | .welcome { 14 | text-align: center; 15 | } 16 | 17 | .welcomeImage { 18 | width: 100%; 19 | max-width: 420px; 20 | } 21 | 22 | .links { 23 | a { 24 | text-decoration: none; 25 | color: "[theme:link, default:#03787c]"; 26 | color: var(--link); // note: CSS Custom Properties support is limited to modern browsers only 27 | 28 | &:hover { 29 | text-decoration: underline; 30 | color: "[theme:linkHovered, default: #014446]"; 31 | color: var(--linkHovered); // note: CSS Custom Properties support is limited to modern browsers only 32 | } 33 | } 34 | } 35 | 36 | .mail { 37 | padding-top: 20px; 38 | } 39 | -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/src/webparts/spFxAadHttpClient/components/SpFxAadHttpClient.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import styles from './SpFxAadHttpClient.module.scss'; 3 | import type { ISpFxAadHttpClientProps } from './ISpFxAadHttpClientProps'; 4 | import { escape } from '@microsoft/sp-lodash-subset'; 5 | 6 | export default class SpFxAadHttpClient extends React.Component { 7 | public render(): React.ReactElement { 8 | const { 9 | userItems, 10 | isDarkTheme, 11 | environmentMessage, 12 | hasTeamsContext, 13 | userDisplayName 14 | } = this.props; 15 | 16 | return ( 17 |
18 |
19 | 20 |

Well done, {escape(userDisplayName)}!

21 |
{environmentMessage}
22 |
Web part property value: {escape(description)}
23 |
24 |
25 |
Mail:
26 |
    27 | {userItems && userItems.map((user) => 28 |
  • 29 | ID: {user.id}
    30 | Email: {user.mail}
    31 | DisplayName: {user.displayName} 32 |
  • 33 | ) 34 | } 35 |
36 |
37 |
38 | ); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/src/webparts/spFxAadHttpClient/loc/en-us.js: -------------------------------------------------------------------------------- 1 | define([], function() { 2 | return { 3 | "PropertyPaneDescription": "Description", 4 | "BasicGroupName": "Group Name", 5 | "DescriptionFieldLabel": "Description Field", 6 | "AppLocalEnvironmentSharePoint": "The app is running on your local environment as SharePoint web part", 7 | "AppLocalEnvironmentTeams": "The app is running on your local environment as Microsoft Teams app", 8 | "AppLocalEnvironmentOffice": "The app is running on your local environment in office.com", 9 | "AppLocalEnvironmentOutlook": "The app is running on your local environment in Outlook", 10 | "AppSharePointEnvironment": "The app is running on SharePoint page", 11 | "AppTeamsTabEnvironment": "The app is running in Microsoft Teams", 12 | "AppOfficeEnvironment": "The app is running in office.com", 13 | "AppOutlookEnvironment": "The app is running in Outlook", 14 | "UnknownEnvironment": "The app is running in an unknown environment" 15 | } 16 | }); -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/src/webparts/spFxAadHttpClient/loc/mystrings.d.ts: -------------------------------------------------------------------------------- 1 | declare interface ISpFxAadHttpClientWebPartStrings { 2 | PropertyPaneDescription: string; 3 | BasicGroupName: string; 4 | DescriptionFieldLabel: string; 5 | AppLocalEnvironmentSharePoint: string; 6 | AppLocalEnvironmentTeams: string; 7 | AppLocalEnvironmentOffice: string; 8 | AppLocalEnvironmentOutlook: string; 9 | AppSharePointEnvironment: string; 10 | AppTeamsTabEnvironment: string; 11 | AppOfficeEnvironment: string; 12 | AppOutlookEnvironment: string; 13 | UnknownEnvironment: string; 14 | } 15 | 16 | declare module 'SpFxAadHttpClientWebPartStrings' { 17 | const strings: ISpFxAadHttpClientWebPartStrings; 18 | export = strings; 19 | } 20 | -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/teams/b37c4dcf-3f2d-4539-a2cd-9afa00e818a5_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Demos/02-aadhttpclient/teams/b37c4dcf-3f2d-4539-a2cd-9afa00e818a5_color.png -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/teams/b37c4dcf-3f2d-4539-a2cd-9afa00e818a5_outline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Demos/02-aadhttpclient/teams/b37c4dcf-3f2d-4539-a2cd-9afa00e818a5_outline.png -------------------------------------------------------------------------------- /Demos/02-aadhttpclient/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./node_modules/@microsoft/rush-stack-compiler-4.7/includes/tsconfig-web.json", 3 | "compilerOptions": { 4 | "target": "es5", 5 | "forceConsistentCasingInFileNames": true, 6 | "module": "esnext", 7 | "moduleResolution": "node", 8 | "jsx": "react", 9 | "declaration": true, 10 | "sourceMap": true, 11 | "experimentalDecorators": true, 12 | "skipLibCheck": true, 13 | "outDir": "lib", 14 | "inlineSources": false, 15 | "noImplicitAny": true, 16 | 17 | "typeRoots": [ 18 | "./node_modules/@types", 19 | "./node_modules/@microsoft" 20 | ], 21 | "types": [ 22 | "webpack-env" 23 | ], 24 | "lib": [ 25 | "es5", 26 | "dom", 27 | "es2015.collection", 28 | "es2015.promise" 29 | ] 30 | }, 31 | "include": [ 32 | "src/**/*.ts", 33 | "src/**/*.tsx" 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /Demos/03-msgraphclient/.eslintrc.js: -------------------------------------------------------------------------------- 1 | require('@rushstack/eslint-config/patch/modern-module-resolution'); 2 | module.exports = { 3 | extends: ['@microsoft/eslint-config-spfx/lib/profiles/react'], 4 | parserOptions: { tsconfigRootDir: __dirname }, 5 | overrides: [ 6 | { 7 | files: ['*.ts', '*.tsx'], 8 | parser: '@typescript-eslint/parser', 9 | 'parserOptions': { 10 | 'project': './tsconfig.json', 11 | 'ecmaVersion': 2018, 12 | 'sourceType': 'module' 13 | }, 14 | rules: { 15 | // Prevent usage of the JavaScript null value, while allowing code to access existing APIs that may require null. https://www.npmjs.com/package/@rushstack/eslint-plugin 16 | '@rushstack/no-new-null': 1, 17 | // Require Jest module mocking APIs to be called before any other statements in their code block. https://www.npmjs.com/package/@rushstack/eslint-plugin 18 | '@rushstack/hoist-jest-mock': 1, 19 | // Require regular expressions to be constructed from string constants rather than dynamically building strings at runtime. https://www.npmjs.com/package/@rushstack/eslint-plugin-security 20 | '@rushstack/security/no-unsafe-regexp': 1, 21 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 22 | '@typescript-eslint/adjacent-overload-signatures': 1, 23 | // RATIONALE: Code is more readable when the type of every variable is immediately obvious. 24 | // Even if the compiler may be able to infer a type, this inference will be unavailable 25 | // to a person who is reviewing a GitHub diff. This rule makes writing code harder, 26 | // but writing code is a much less important activity than reading it. 27 | // 28 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 29 | '@typescript-eslint/explicit-function-return-type': [ 30 | 1, 31 | { 32 | 'allowExpressions': true, 33 | 'allowTypedFunctionExpressions': true, 34 | 'allowHigherOrderFunctions': false 35 | } 36 | ], 37 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 38 | // Rationale to disable: although this is a recommended rule, it is up to dev to select coding style. 39 | // Set to 1 (warning) or 2 (error) to enable. 40 | '@typescript-eslint/explicit-member-accessibility': 0, 41 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 42 | '@typescript-eslint/no-array-constructor': 1, 43 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 44 | // 45 | // RATIONALE: The "any" keyword disables static type checking, the main benefit of using TypeScript. 46 | // This rule should be suppressed only in very special cases such as JSON.stringify() 47 | // where the type really can be anything. Even if the type is flexible, another type 48 | // may be more appropriate such as "unknown", "{}", or "Record". 49 | '@typescript-eslint/no-explicit-any': 1, 50 | // RATIONALE: The #1 rule of promises is that every promise chain must be terminated by a catch() 51 | // handler. Thus wherever a Promise arises, the code must either append a catch handler, 52 | // or else return the object to a caller (who assumes this responsibility). Unterminated 53 | // promise chains are a serious issue. Besides causing errors to be silently ignored, 54 | // they can also cause a NodeJS process to terminate unexpectedly. 55 | '@typescript-eslint/no-floating-promises': 2, 56 | // RATIONALE: Catches a common coding mistake. 57 | '@typescript-eslint/no-for-in-array': 2, 58 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 59 | '@typescript-eslint/no-misused-new': 2, 60 | // RATIONALE: The "namespace" keyword is not recommended for organizing code because JavaScript lacks 61 | // a "using" statement to traverse namespaces. Nested namespaces prevent certain bundler 62 | // optimizations. If you are declaring loose functions/variables, it's better to make them 63 | // static members of a class, since classes support property getters and their private 64 | // members are accessible by unit tests. Also, the exercise of choosing a meaningful 65 | // class name tends to produce more discoverable APIs: for example, search+replacing 66 | // the function "reverse()" is likely to return many false matches, whereas if we always 67 | // write "Text.reverse()" is more unique. For large scale organization, it's recommended 68 | // to decompose your code into separate NPM packages, which ensures that component 69 | // dependencies are tracked more conscientiously. 70 | // 71 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 72 | '@typescript-eslint/no-namespace': [ 73 | 1, 74 | { 75 | 'allowDeclarations': false, 76 | 'allowDefinitionFiles': false 77 | } 78 | ], 79 | // RATIONALE: Parameter properties provide a shorthand such as "constructor(public title: string)" 80 | // that avoids the effort of declaring "title" as a field. This TypeScript feature makes 81 | // code easier to write, but arguably sacrifices readability: In the notes for 82 | // "@typescript-eslint/member-ordering" we pointed out that fields are central to 83 | // a class's design, so we wouldn't want to bury them in a constructor signature 84 | // just to save some typing. 85 | // 86 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 87 | // Set to 1 (warning) or 2 (error) to enable the rule 88 | '@typescript-eslint/parameter-properties': 0, 89 | // RATIONALE: When left in shipping code, unused variables often indicate a mistake. Dead code 90 | // may impact performance. 91 | // 92 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 93 | '@typescript-eslint/no-unused-vars': [ 94 | 1, 95 | { 96 | 'vars': 'all', 97 | // Unused function arguments often indicate a mistake in JavaScript code. However in TypeScript code, 98 | // the compiler catches most of those mistakes, and unused arguments are fairly common for type signatures 99 | // that are overriding a base class method or implementing an interface. 100 | 'args': 'none' 101 | } 102 | ], 103 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 104 | '@typescript-eslint/no-use-before-define': [ 105 | 2, 106 | { 107 | 'functions': false, 108 | 'classes': true, 109 | 'variables': true, 110 | 'enums': true, 111 | 'typedefs': true 112 | } 113 | ], 114 | // Disallows require statements except in import statements. 115 | // In other words, the use of forms such as var foo = require("foo") are banned. Instead use ES6 style imports or import foo = require("foo") imports. 116 | '@typescript-eslint/no-var-requires': 'error', 117 | // RATIONALE: The "module" keyword is deprecated except when describing legacy libraries. 118 | // 119 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 120 | '@typescript-eslint/prefer-namespace-keyword': 1, 121 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 122 | // Rationale to disable: it's up to developer to decide if he wants to add type annotations 123 | // Set to 1 (warning) or 2 (error) to enable the rule 124 | '@typescript-eslint/no-inferrable-types': 0, 125 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 126 | // Rationale to disable: declaration of empty interfaces may be helpful for generic types scenarios 127 | '@typescript-eslint/no-empty-interface': 0, 128 | // RATIONALE: This rule warns if setters are defined without getters, which is probably a mistake. 129 | 'accessor-pairs': 1, 130 | // RATIONALE: In TypeScript, if you write x["y"] instead of x.y, it disables type checking. 131 | 'dot-notation': [ 132 | 1, 133 | { 134 | 'allowPattern': '^_' 135 | } 136 | ], 137 | // RATIONALE: Catches code that is likely to be incorrect 138 | 'eqeqeq': 1, 139 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 140 | 'for-direction': 1, 141 | // RATIONALE: Catches a common coding mistake. 142 | 'guard-for-in': 2, 143 | // RATIONALE: If you have more than 2,000 lines in a single source file, it's probably time 144 | // to split up your code. 145 | 'max-lines': ['warn', { max: 2000 }], 146 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 147 | 'no-async-promise-executor': 2, 148 | // RATIONALE: Deprecated language feature. 149 | 'no-caller': 2, 150 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 151 | 'no-compare-neg-zero': 2, 152 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 153 | 'no-cond-assign': 2, 154 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 155 | 'no-constant-condition': 1, 156 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 157 | 'no-control-regex': 2, 158 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 159 | 'no-debugger': 1, 160 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 161 | 'no-delete-var': 2, 162 | // RATIONALE: Catches code that is likely to be incorrect 163 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 164 | 'no-duplicate-case': 2, 165 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 166 | 'no-empty': 1, 167 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 168 | 'no-empty-character-class': 2, 169 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 170 | 'no-empty-pattern': 1, 171 | // RATIONALE: Eval is a security concern and a performance concern. 172 | 'no-eval': 1, 173 | // RATIONALE: Catches code that is likely to be incorrect 174 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 175 | 'no-ex-assign': 2, 176 | // RATIONALE: System types are global and should not be tampered with in a scalable code base. 177 | // If two different libraries (or two versions of the same library) both try to modify 178 | // a type, only one of them can win. Polyfills are acceptable because they implement 179 | // a standardized interoperable contract, but polyfills are generally coded in plain 180 | // JavaScript. 181 | 'no-extend-native': 1, 182 | // Disallow unnecessary labels 183 | 'no-extra-label': 1, 184 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 185 | 'no-fallthrough': 2, 186 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 187 | 'no-func-assign': 1, 188 | // RATIONALE: Catches a common coding mistake. 189 | 'no-implied-eval': 2, 190 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 191 | 'no-invalid-regexp': 2, 192 | // RATIONALE: Catches a common coding mistake. 193 | 'no-label-var': 2, 194 | // RATIONALE: Eliminates redundant code. 195 | 'no-lone-blocks': 1, 196 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 197 | 'no-misleading-character-class': 2, 198 | // RATIONALE: Catches a common coding mistake. 199 | 'no-multi-str': 2, 200 | // RATIONALE: It's generally a bad practice to call "new Thing()" without assigning the result to 201 | // a variable. Either it's part of an awkward expression like "(new Thing()).doSomething()", 202 | // or else implies that the constructor is doing nontrivial computations, which is often 203 | // a poor class design. 204 | 'no-new': 1, 205 | // RATIONALE: Obsolete language feature that is deprecated. 206 | 'no-new-func': 2, 207 | // RATIONALE: Obsolete language feature that is deprecated. 208 | 'no-new-object': 2, 209 | // RATIONALE: Obsolete notation. 210 | 'no-new-wrappers': 1, 211 | // RATIONALE: Catches code that is likely to be incorrect 212 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 213 | 'no-octal': 2, 214 | // RATIONALE: Catches code that is likely to be incorrect 215 | 'no-octal-escape': 2, 216 | // RATIONALE: Catches code that is likely to be incorrect 217 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 218 | 'no-regex-spaces': 2, 219 | // RATIONALE: Catches a common coding mistake. 220 | 'no-return-assign': 2, 221 | // RATIONALE: Security risk. 222 | 'no-script-url': 1, 223 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 224 | 'no-self-assign': 2, 225 | // RATIONALE: Catches a common coding mistake. 226 | 'no-self-compare': 2, 227 | // RATIONALE: This avoids statements such as "while (a = next(), a && a.length);" that use 228 | // commas to create compound expressions. In general code is more readable if each 229 | // step is split onto a separate line. This also makes it easier to set breakpoints 230 | // in the debugger. 231 | 'no-sequences': 1, 232 | // RATIONALE: Catches code that is likely to be incorrect 233 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 234 | 'no-shadow-restricted-names': 2, 235 | // RATIONALE: Obsolete language feature that is deprecated. 236 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 237 | 'no-sparse-arrays': 2, 238 | // RATIONALE: Although in theory JavaScript allows any possible data type to be thrown as an exception, 239 | // such flexibility adds pointless complexity, by requiring every catch block to test 240 | // the type of the object that it receives. Whereas if catch blocks can always assume 241 | // that their object implements the "Error" contract, then the code is simpler, and 242 | // we generally get useful additional information like a call stack. 243 | 'no-throw-literal': 2, 244 | // RATIONALE: Catches a common coding mistake. 245 | 'no-unmodified-loop-condition': 1, 246 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 247 | 'no-unsafe-finally': 2, 248 | // RATIONALE: Catches a common coding mistake. 249 | 'no-unused-expressions': 1, 250 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 251 | 'no-unused-labels': 1, 252 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 253 | 'no-useless-catch': 1, 254 | // RATIONALE: Avoids a potential performance problem. 255 | 'no-useless-concat': 1, 256 | // RATIONALE: The "var" keyword is deprecated because of its confusing "hoisting" behavior. 257 | // Always use "let" or "const" instead. 258 | // 259 | // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json 260 | 'no-var': 2, 261 | // RATIONALE: Generally not needed in modern code. 262 | 'no-void': 1, 263 | // RATIONALE: Obsolete language feature that is deprecated. 264 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 265 | 'no-with': 2, 266 | // RATIONALE: Makes logic easier to understand, since constants always have a known value 267 | // @typescript-eslint\eslint-plugin\dist\configs\eslint-recommended.js 268 | 'prefer-const': 1, 269 | // RATIONALE: Catches a common coding mistake where "resolve" and "reject" are confused. 270 | 'promise/param-names': 2, 271 | // RATIONALE: Catches code that is likely to be incorrect 272 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 273 | 'require-atomic-updates': 2, 274 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 275 | 'require-yield': 1, 276 | // "Use strict" is redundant when using the TypeScript compiler. 277 | 'strict': [ 278 | 2, 279 | 'never' 280 | ], 281 | // RATIONALE: Catches code that is likely to be incorrect 282 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 283 | 'use-isnan': 2, 284 | // STANDARDIZED BY: eslint\conf\eslint-recommended.js 285 | // Set to 1 (warning) or 2 (error) to enable. 286 | // Rationale to disable: !!{} 287 | 'no-extra-boolean-cast': 0, 288 | // ==================================================================== 289 | // @microsoft/eslint-plugin-spfx 290 | // ==================================================================== 291 | '@microsoft/spfx/import-requires-chunk-name': 1, 292 | '@microsoft/spfx/no-require-ensure': 2, 293 | '@microsoft/spfx/pair-react-dom-render-unmount': 1 294 | } 295 | }, 296 | { 297 | // For unit tests, we can be a little bit less strict. The settings below revise the 298 | // defaults specified in the extended configurations, as well as above. 299 | files: [ 300 | // Test files 301 | '*.test.ts', 302 | '*.test.tsx', 303 | '*.spec.ts', 304 | '*.spec.tsx', 305 | 306 | // Facebook convention 307 | '**/__mocks__/*.ts', 308 | '**/__mocks__/*.tsx', 309 | '**/__tests__/*.ts', 310 | '**/__tests__/*.tsx', 311 | 312 | // Microsoft convention 313 | '**/test/*.ts', 314 | '**/test/*.tsx' 315 | ], 316 | rules: {} 317 | } 318 | ] 319 | }; -------------------------------------------------------------------------------- /Demos/03-msgraphclient/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Dependency directories 7 | node_modules 8 | 9 | # Build generated files 10 | dist 11 | lib 12 | release 13 | solution 14 | temp 15 | *.sppkg 16 | .heft 17 | 18 | # Coverage directory used by tools like istanbul 19 | coverage 20 | 21 | # OSX 22 | .DS_Store 23 | 24 | # Visual Studio files 25 | .ntvs_analysis.dat 26 | .vs 27 | bin 28 | obj 29 | 30 | # Resx Generated Code 31 | *.resx.ts 32 | 33 | # Styles Generated Code 34 | *.scss.ts 35 | -------------------------------------------------------------------------------- /Demos/03-msgraphclient/.npmignore: -------------------------------------------------------------------------------- 1 | !dist 2 | config 3 | 4 | gulpfile.js 5 | 6 | release 7 | src 8 | temp 9 | 10 | tsconfig.json 11 | tslint.json 12 | 13 | *.log 14 | 15 | .yo-rc.json 16 | .vscode 17 | -------------------------------------------------------------------------------- /Demos/03-msgraphclient/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Hosted workbench", 6 | "type": "msedge", 7 | "request": "launch", 8 | "url": "https://{tenantDomain}/_layouts/workbench.aspx", 9 | "webRoot": "${workspaceRoot}", 10 | "sourceMaps": true, 11 | "sourceMapPathOverrides": { 12 | "webpack:///.././src/*": "${webRoot}/src/*", 13 | "webpack:///../../../src/*": "${webRoot}/src/*", 14 | "webpack:///../../../../src/*": "${webRoot}/src/*", 15 | "webpack:///../../../../../src/*": "${webRoot}/src/*" 16 | }, 17 | "runtimeArgs": [ 18 | "--remote-debugging-port=9222", 19 | "-incognito" 20 | ] 21 | } 22 | ] 23 | } -------------------------------------------------------------------------------- /Demos/03-msgraphclient/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | // Configure glob patterns for excluding files and folders in the file explorer. 4 | "files.exclude": { 5 | "**/.git": true, 6 | "**/.DS_Store": true, 7 | "**/bower_components": true, 8 | "**/coverage": true, 9 | "**/jest-output": true, 10 | "**/lib-amd": true, 11 | "src/**/*.scss.ts": true 12 | }, 13 | "typescript.tsdk": ".\\node_modules\\typescript\\lib" 14 | } -------------------------------------------------------------------------------- /Demos/03-msgraphclient/.yo-rc.json: -------------------------------------------------------------------------------- 1 | { 2 | "@microsoft/generator-sharepoint": { 3 | "plusBeta": false, 4 | "isCreatingSolution": true, 5 | "nodeVersion": "18.20.4", 6 | "sdksVersions": { 7 | "@microsoft/microsoft-graph-client": "3.0.2", 8 | "@microsoft/teams-js": "2.24.0" 9 | }, 10 | "version": "1.20.0", 11 | "libraryName": "ms-graph-sp-fx", 12 | "libraryId": "80cc0416-290c-4eed-ae30-c3f4abc23aca", 13 | "environment": "spo", 14 | "packageManager": "npm", 15 | "solutionName": "MSGraphSPFx", 16 | "solutionShortDescription": "MSGraphSPFx description", 17 | "skipFeatureDeployment": true, 18 | "isDomainIsolated": false, 19 | "componentType": "webpart" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Demos/03-msgraphclient/README.md: -------------------------------------------------------------------------------- 1 | # ms-graph-sp-fx 2 | 3 | ## Summary 4 | 5 | Short summary on functionality and used technologies. 6 | 7 | [picture of the solution in action, if possible] 8 | 9 | ## Used SharePoint Framework Version 10 | 11 | ![version](https://img.shields.io/badge/version-1.20.0-green.svg) 12 | 13 | ## Applies to 14 | 15 | - [SharePoint Framework](https://aka.ms/spfx) 16 | - [Microsoft 365 tenant](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant) 17 | 18 | > Get your own free development tenant by subscribing to [Microsoft 365 developer program](http://aka.ms/o365devprogram) 19 | 20 | ## Prerequisites 21 | 22 | > Any special pre-requisites? 23 | 24 | ## Solution 25 | 26 | | Solution | Author(s) | 27 | | ----------- | ------------------------------------------------------- | 28 | | folder name | Author details (name, company, twitter alias with link) | 29 | 30 | ## Version history 31 | 32 | | Version | Date | Comments | 33 | | ------- | ---------------- | --------------- | 34 | | 1.1 | March 10, 2021 | Update comment | 35 | | 1.0 | January 29, 2021 | Initial release | 36 | 37 | ## Disclaimer 38 | 39 | **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.** 40 | 41 | --- 42 | 43 | ## Minimal Path to Awesome 44 | 45 | - Clone this repository 46 | - Ensure that you are at the solution folder 47 | - in the command-line run: 48 | - **npm install** 49 | - **gulp serve** 50 | 51 | > Include any additional steps as needed. 52 | 53 | ## Features 54 | 55 | Description of the extension that expands upon high-level summary above. 56 | 57 | This extension illustrates the following concepts: 58 | 59 | - topic 1 60 | - topic 2 61 | - topic 3 62 | 63 | > Notice that better pictures and documentation will increase the sample usage and the value you are providing for others. Thanks for your submissions advance. 64 | 65 | > Share your web part with others through Microsoft 365 Patterns and Practices program to get visibility and exposure. More details on the community, open-source projects and other activities from http://aka.ms/m365pnp. 66 | 67 | ## References 68 | 69 | - [Getting started with SharePoint Framework](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant) 70 | - [Building for Microsoft teams](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/build-for-teams-overview) 71 | - [Use Microsoft Graph in your solution](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/using-microsoft-graph-apis) 72 | - [Publish SharePoint Framework applications to the Marketplace](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/publish-to-marketplace-overview) 73 | - [Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) - Guidance, tooling, samples and open-source controls for your Microsoft 365 development 74 | -------------------------------------------------------------------------------- /Demos/03-msgraphclient/config/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json", 3 | "version": "2.0", 4 | "bundles": { 5 | "graph-persona-web-part": { 6 | "components": [ 7 | { 8 | "entrypoint": "./lib/webparts/graphPersona/GraphPersonaWebPart.js", 9 | "manifest": "./src/webparts/graphPersona/GraphPersonaWebPart.manifest.json" 10 | } 11 | ] 12 | } 13 | }, 14 | "externals": {}, 15 | "localizedResources": { 16 | "GraphPersonaWebPartStrings": "lib/webparts/graphPersona/loc/{locale}.js" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Demos/03-msgraphclient/config/deploy-azure-storage.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json", 3 | "workingDir": "./release/assets/", 4 | "account": "", 5 | "container": "ms-graph-sp-fx", 6 | "accessKey": "" 7 | } -------------------------------------------------------------------------------- /Demos/03-msgraphclient/config/package-solution.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json", 3 | "solution": { 4 | "name": "ms-graph-sp-fx-client-side-solution", 5 | "id": "80cc0416-290c-4eed-ae30-c3f4abc23aca", 6 | "version": "1.0.0.0", 7 | "includeClientSideAssets": true, 8 | "skipFeatureDeployment": true, 9 | "isDomainIsolated": false, 10 | "webApiPermissionRequests": [ 11 | { 12 | "resource": "Microsoft Graph", 13 | "scope": "User.ReadBasic.All" 14 | } 15 | ], 16 | "developer": { 17 | "name": "", 18 | "websiteUrl": "", 19 | "privacyUrl": "", 20 | "termsOfUseUrl": "", 21 | "mpnId": "Undefined-1.20.0" 22 | }, 23 | "metadata": { 24 | "shortDescription": { 25 | "default": "MSGraphSPFx description" 26 | }, 27 | "longDescription": { 28 | "default": "MSGraphSPFx description" 29 | }, 30 | "screenshotPaths": [], 31 | "videoUrl": "", 32 | "categories": [] 33 | }, 34 | "features": [ 35 | { 36 | "title": "ms-graph-sp-fx Feature", 37 | "description": "The feature that activates elements of the ms-graph-sp-fx solution.", 38 | "id": "2411e168-d065-4b2c-8d27-a8783f315b42", 39 | "version": "1.0.0.0" 40 | } 41 | ] 42 | }, 43 | "paths": { 44 | "zippedPackage": "solution/ms-graph-sp-fx.sppkg" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Demos/03-msgraphclient/config/sass.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://developer.microsoft.com/json-schemas/core-build/sass.schema.json" 3 | } -------------------------------------------------------------------------------- /Demos/03-msgraphclient/config/serve.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/spfx-serve.schema.json", 3 | "port": 4321, 4 | "https": true, 5 | "initialPage": "https://{tenantDomain}/_layouts/workbench.aspx" 6 | } 7 | -------------------------------------------------------------------------------- /Demos/03-msgraphclient/config/write-manifests.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json", 3 | "cdnBasePath": "" 4 | } -------------------------------------------------------------------------------- /Demos/03-msgraphclient/gulpfile.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const build = require('@microsoft/sp-build-web'); 4 | 5 | build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`); 6 | 7 | var getTasks = build.rig.getTasks; 8 | build.rig.getTasks = function () { 9 | var result = getTasks.call(build.rig); 10 | 11 | result.set('serve', result.get('serve-deprecated')); 12 | 13 | return result; 14 | }; 15 | 16 | build.initialize(require('gulp')); 17 | -------------------------------------------------------------------------------- /Demos/03-msgraphclient/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ms-graph-sp-fx", 3 | "version": "0.0.1", 4 | "private": true, 5 | "engines": { 6 | "node": ">=18.17.1 <19.0.0" 7 | }, 8 | "main": "lib/index.js", 9 | "scripts": { 10 | "build": "gulp bundle", 11 | "clean": "gulp clean", 12 | "test": "gulp test" 13 | }, 14 | "dependencies": { 15 | "tslib": "2.3.1", 16 | "react": "17.0.1", 17 | "react-dom": "17.0.1", 18 | "@fluentui/react": "^8.106.4", 19 | "@microsoft/sp-core-library": "1.20.0", 20 | "@microsoft/sp-component-base": "1.20.0", 21 | "@microsoft/sp-property-pane": "1.20.0", 22 | "@microsoft/sp-webpart-base": "1.20.0", 23 | "@microsoft/sp-lodash-subset": "1.20.0", 24 | "@microsoft/sp-office-ui-fabric-core": "1.20.0" 25 | }, 26 | "devDependencies": { 27 | "@microsoft/rush-stack-compiler-4.7": "0.1.0", 28 | "@rushstack/eslint-config": "4.0.1", 29 | "@microsoft/eslint-plugin-spfx": "1.20.2", 30 | "@microsoft/eslint-config-spfx": "1.20.2", 31 | "@microsoft/sp-build-web": "1.20.2", 32 | "@types/webpack-env": "~1.15.2", 33 | "ajv": "^6.12.5", 34 | "eslint": "8.57.0", 35 | "gulp": "4.0.2", 36 | "typescript": "4.7.4", 37 | "@types/react": "17.0.45", 38 | "@types/react-dom": "17.0.17", 39 | "eslint-plugin-react-hooks": "4.3.0", 40 | "@microsoft/sp-module-interfaces": "1.20.2" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Demos/03-msgraphclient/src/index.ts: -------------------------------------------------------------------------------- 1 | // A file is required to be in the root of the /src directory by the TypeScript compiler 2 | -------------------------------------------------------------------------------- /Demos/03-msgraphclient/src/webparts/graphPersona/GraphPersonaWebPart.manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json", 3 | "id": "10fb665f-3fd8-411c-b68c-947c865d58f6", 4 | "alias": "GraphPersonaWebPart", 5 | "componentType": "WebPart", 6 | 7 | // The "*" signifies that the version should be taken from the package.json 8 | "version": "*", 9 | "manifestVersion": 2, 10 | 11 | // If true, the component can only be installed on sites where Custom Script is allowed. 12 | // Components that allow authors to embed arbitrary script code should set this to true. 13 | // https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f 14 | "requiresCustomScript": false, 15 | "supportedHosts": ["SharePointWebPart", "TeamsPersonalApp", "TeamsTab", "SharePointFullPage"], 16 | "supportsThemeVariants": true, 17 | 18 | "preconfiguredEntries": [{ 19 | "groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Advanced 20 | "group": { "default": "Advanced" }, 21 | "title": { "default": "GraphPersona" }, 22 | "description": { "default": "GraphPersona description" }, 23 | "officeFabricIconFontName": "Page", 24 | "properties": { 25 | "description": "GraphPersona" 26 | } 27 | }] 28 | } 29 | -------------------------------------------------------------------------------- /Demos/03-msgraphclient/src/webparts/graphPersona/GraphPersonaWebPart.ts: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import * as ReactDom from 'react-dom'; 3 | import { Version } from '@microsoft/sp-core-library'; 4 | import { 5 | type IPropertyPaneConfiguration, 6 | PropertyPaneTextField 7 | } from '@microsoft/sp-property-pane'; 8 | import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base'; 9 | import { IReadonlyTheme } from '@microsoft/sp-component-base'; 10 | 11 | import * as strings from 'GraphPersonaWebPartStrings'; 12 | import GraphPersona from './components/GraphPersona'; 13 | import { IGraphPersonaProps } from './components/IGraphPersonaProps'; 14 | 15 | import { MSGraphClientV3 } from '@microsoft/sp-http'; 16 | 17 | export interface IGraphPersonaWebPartProps { 18 | description: string; 19 | } 20 | 21 | export default class GraphPersonaWebPart extends BaseClientSideWebPart { 22 | 23 | private _isDarkTheme: boolean = false; 24 | private _environmentMessage: string = ''; 25 | 26 | protected get isRenderAsync(): boolean { 27 | return true; 28 | } 29 | 30 | public async render(): Promise { 31 | const client: MSGraphClientV3 = await this.context.msGraphClientFactory.getClient('3'); 32 | 33 | const element: React.ReactElement = React.createElement( 34 | GraphPersona, 35 | { 36 | graphClient: client, 37 | isDarkTheme: this._isDarkTheme, 38 | environmentMessage: this._environmentMessage, 39 | hasTeamsContext: !!this.context.sdks.microsoftTeams, 40 | userDisplayName: this.context.pageContext.user.displayName 41 | } 42 | ); 43 | 44 | ReactDom.render(element, this.domElement); 45 | 46 | this.renderCompleted(); 47 | } 48 | 49 | protected renderCompleted(): void { 50 | super.renderCompleted(); 51 | } 52 | 53 | protected onInit(): Promise { 54 | return this._getEnvironmentMessage().then(message => { 55 | this._environmentMessage = message; 56 | }); 57 | } 58 | 59 | 60 | 61 | private _getEnvironmentMessage(): Promise { 62 | if (!!this.context.sdks.microsoftTeams) { // running in Teams, office.com or Outlook 63 | return this.context.sdks.microsoftTeams.teamsJs.app.getContext() 64 | .then(context => { 65 | let environmentMessage: string = ''; 66 | switch (context.app.host.name) { 67 | case 'Office': // running in Office 68 | environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentOffice : strings.AppOfficeEnvironment; 69 | break; 70 | case 'Outlook': // running in Outlook 71 | environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentOutlook : strings.AppOutlookEnvironment; 72 | break; 73 | case 'Teams': // running in Teams 74 | case 'TeamsModern': 75 | environmentMessage = this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentTeams : strings.AppTeamsTabEnvironment; 76 | break; 77 | default: 78 | environmentMessage = strings.UnknownEnvironment; 79 | } 80 | 81 | return environmentMessage; 82 | }); 83 | } 84 | 85 | return Promise.resolve(this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentSharePoint : strings.AppSharePointEnvironment); 86 | } 87 | 88 | protected onThemeChanged(currentTheme: IReadonlyTheme | undefined): void { 89 | if (!currentTheme) { 90 | return; 91 | } 92 | 93 | this._isDarkTheme = !!currentTheme.isInverted; 94 | const { 95 | semanticColors 96 | } = currentTheme; 97 | 98 | if (semanticColors) { 99 | this.domElement.style.setProperty('--bodyText', semanticColors.bodyText || null); 100 | this.domElement.style.setProperty('--link', semanticColors.link || null); 101 | this.domElement.style.setProperty('--linkHovered', semanticColors.linkHovered || null); 102 | } 103 | 104 | } 105 | 106 | protected onDispose(): void { 107 | ReactDom.unmountComponentAtNode(this.domElement); 108 | } 109 | 110 | protected get dataVersion(): Version { 111 | return Version.parse('1.0'); 112 | } 113 | 114 | protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration { 115 | return { 116 | pages: [ 117 | { 118 | header: { 119 | description: strings.PropertyPaneDescription 120 | }, 121 | groups: [ 122 | { 123 | groupName: strings.BasicGroupName, 124 | groupFields: [ 125 | PropertyPaneTextField('description', { 126 | label: strings.DescriptionFieldLabel 127 | }) 128 | ] 129 | } 130 | ] 131 | } 132 | ] 133 | }; 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /Demos/03-msgraphclient/src/webparts/graphPersona/assets/welcome-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Demos/03-msgraphclient/src/webparts/graphPersona/assets/welcome-dark.png -------------------------------------------------------------------------------- /Demos/03-msgraphclient/src/webparts/graphPersona/assets/welcome-light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Demos/03-msgraphclient/src/webparts/graphPersona/assets/welcome-light.png -------------------------------------------------------------------------------- /Demos/03-msgraphclient/src/webparts/graphPersona/components/GraphPersona.module.scss: -------------------------------------------------------------------------------- 1 | @import '~@fluentui/react/dist/sass/References.scss'; 2 | 3 | .graphPersona { 4 | overflow: hidden; 5 | padding: 1em; 6 | color: "[theme:bodyText, default: #323130]"; 7 | color: var(--bodyText); 8 | &.teams { 9 | font-family: $ms-font-family-fallbacks; 10 | } 11 | } 12 | 13 | .welcome { 14 | text-align: center; 15 | } 16 | 17 | .welcomeImage { 18 | width: 100%; 19 | max-width: 420px; 20 | } 21 | 22 | .links { 23 | a { 24 | text-decoration: none; 25 | color: "[theme:link, default:#03787c]"; 26 | color: var(--link); // note: CSS Custom Properties support is limited to modern browsers only 27 | 28 | &:hover { 29 | text-decoration: underline; 30 | color: "[theme:linkHovered, default: #014446]"; 31 | color: var(--linkHovered); // note: CSS Custom Properties support is limited to modern browsers only 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Demos/03-msgraphclient/src/webparts/graphPersona/components/GraphPersona.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import styles from './GraphPersona.module.scss'; 3 | import type { IGraphPersonaProps } from './IGraphPersonaProps'; 4 | 5 | import { IGraphPersonaState } from './IGraphPersonaState'; 6 | 7 | import { GraphError, ResponseType } from '@microsoft/microsoft-graph-client'; 8 | import * as MicrosoftGraph from '@microsoft/microsoft-graph-types'; 9 | 10 | import { 11 | Persona, 12 | PersonaSize 13 | } from 'office-ui-fabric-react/lib/components/Persona'; 14 | 15 | import { Link } from 'office-ui-fabric-react/lib/components/Link'; 16 | 17 | export default class GraphPersona extends React.Component { 18 | 19 | constructor(props: IGraphPersonaProps) { 20 | super(props); 21 | 22 | this.state = { 23 | name: '', 24 | email: '', 25 | phone: '', 26 | image: null 27 | }; 28 | } 29 | 30 | public render(): React.ReactElement { 31 | const { 32 | description, 33 | isDarkTheme, 34 | environmentMessage, 35 | hasTeamsContext, 36 | userDisplayName 37 | } = this.props; 38 | 39 | return ( 40 | 47 | ); 48 | } 49 | 50 | private _renderMail = (): JSX.Element => { 51 | if (this.state.email) { 52 | return {this.state.email}; 53 | } else { 54 | return
; 55 | } 56 | } 57 | 58 | private _renderPhone = (): JSX.Element => { 59 | if (this.state.phone) { 60 | return {this.state.phone}; 61 | } else { 62 | return
; 63 | } 64 | } 65 | 66 | public componentDidMount(): void { 67 | /* eslint-disable @typescript-eslint/no-floating-promises */ 68 | this.props.graphClient 69 | .api('me') 70 | .get((error: GraphError, user: MicrosoftGraph.User) => { 71 | this.setState({ 72 | name: user.displayName, 73 | email: user.mail, 74 | phone: user.businessPhones[0] 75 | }); 76 | }); 77 | 78 | this.props.graphClient 79 | .api('/me/photo/$value') 80 | .responseType(ResponseType.BLOB) 81 | .get((error: GraphError, photoResponse: Blob) => { 82 | const blobUrl = window.URL.createObjectURL(photoResponse); 83 | this.setState({ image: blobUrl }); 84 | }); 85 | /* eslint-enable @typescript-eslint/no-floating-promises */ 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /Demos/03-msgraphclient/src/webparts/graphPersona/components/IGraphPersonaProps.ts: -------------------------------------------------------------------------------- 1 | export interface IGraphPersonaProps { 2 | description: string; 3 | isDarkTheme: boolean; 4 | environmentMessage: string; 5 | hasTeamsContext: boolean; 6 | userDisplayName: string; 7 | } 8 | -------------------------------------------------------------------------------- /Demos/03-msgraphclient/src/webparts/graphPersona/loc/en-us.js: -------------------------------------------------------------------------------- 1 | define([], function() { 2 | return { 3 | "PropertyPaneDescription": "Description", 4 | "BasicGroupName": "Group Name", 5 | "DescriptionFieldLabel": "Description Field", 6 | "AppLocalEnvironmentSharePoint": "The app is running on your local environment as SharePoint web part", 7 | "AppLocalEnvironmentTeams": "The app is running on your local environment as Microsoft Teams app", 8 | "AppLocalEnvironmentOffice": "The app is running on your local environment in office.com", 9 | "AppLocalEnvironmentOutlook": "The app is running on your local environment in Outlook", 10 | "AppSharePointEnvironment": "The app is running on SharePoint page", 11 | "AppTeamsTabEnvironment": "The app is running in Microsoft Teams", 12 | "AppOfficeEnvironment": "The app is running in office.com", 13 | "AppOutlookEnvironment": "The app is running in Outlook", 14 | "UnknownEnvironment": "The app is running in an unknown environment" 15 | } 16 | }); -------------------------------------------------------------------------------- /Demos/03-msgraphclient/src/webparts/graphPersona/loc/mystrings.d.ts: -------------------------------------------------------------------------------- 1 | declare interface IGraphPersonaWebPartStrings { 2 | PropertyPaneDescription: string; 3 | BasicGroupName: string; 4 | DescriptionFieldLabel: string; 5 | AppLocalEnvironmentSharePoint: string; 6 | AppLocalEnvironmentTeams: string; 7 | AppLocalEnvironmentOffice: string; 8 | AppLocalEnvironmentOutlook: string; 9 | AppSharePointEnvironment: string; 10 | AppTeamsTabEnvironment: string; 11 | AppOfficeEnvironment: string; 12 | AppOutlookEnvironment: string; 13 | UnknownEnvironment: string; 14 | } 15 | 16 | declare module 'GraphPersonaWebPartStrings' { 17 | const strings: IGraphPersonaWebPartStrings; 18 | export = strings; 19 | } 20 | -------------------------------------------------------------------------------- /Demos/03-msgraphclient/teams/10fb665f-3fd8-411c-b68c-947c865d58f6_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Demos/03-msgraphclient/teams/10fb665f-3fd8-411c-b68c-947c865d58f6_color.png -------------------------------------------------------------------------------- /Demos/03-msgraphclient/teams/10fb665f-3fd8-411c-b68c-947c865d58f6_outline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Demos/03-msgraphclient/teams/10fb665f-3fd8-411c-b68c-947c865d58f6_outline.png -------------------------------------------------------------------------------- /Demos/03-msgraphclient/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./node_modules/@microsoft/rush-stack-compiler-4.7/includes/tsconfig-web.json", 3 | "compilerOptions": { 4 | "target": "es5", 5 | "forceConsistentCasingInFileNames": true, 6 | "module": "esnext", 7 | "moduleResolution": "node", 8 | "jsx": "react", 9 | "declaration": true, 10 | "sourceMap": true, 11 | "experimentalDecorators": true, 12 | "skipLibCheck": true, 13 | "outDir": "lib", 14 | "inlineSources": false, 15 | "noImplicitAny": true, 16 | 17 | "typeRoots": [ 18 | "./node_modules/@types", 19 | "./node_modules/@microsoft" 20 | ], 21 | "types": [ 22 | "webpack-env" 23 | ], 24 | "lib": [ 25 | "es5", 26 | "dom", 27 | "es2015.collection", 28 | "es2015.promise" 29 | ] 30 | }, 31 | "include": [ 32 | "src/**/*.ts", 33 | "src/**/*.tsx" 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /Demos/README.md: -------------------------------------------------------------------------------- 1 | # Microsoft SharePoint Framework Training Module - Leverage Microsoft Graph & third-party APIs 2 | 3 | This folder contains demos for the SharePoint Framework training module on Leverage Microsoft Graph & third-party APIs 4 | 5 | ## Demos 6 | 7 | - [Call anonymous third-party REST APIs](./01-httpclient) 8 | - [Call Azure AD secured REST APIs](./02-aadhttpclient) 9 | - [Call Microsoft Graph from SharePoint Framework components](./03-msgraphclient) 10 | 11 | ## Running demonstrations 12 | 13 | Each demonstration is included as source code for convenience. 14 | -------------------------------------------------------------------------------- /Images/aad-addpackage-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Images/aad-addpackage-01.png -------------------------------------------------------------------------------- /Images/aad-addpackage-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Images/aad-addpackage-02.png -------------------------------------------------------------------------------- /Images/aad-addpackage-03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Images/aad-addpackage-03.png -------------------------------------------------------------------------------- /Images/aad-addpackage-04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Images/aad-addpackage-04.png -------------------------------------------------------------------------------- /Images/aad-addpackage-05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Images/aad-addpackage-05.png -------------------------------------------------------------------------------- /Images/aad-addpackage-06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Images/aad-addpackage-06.png -------------------------------------------------------------------------------- /Images/aad-addpackage-07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Images/aad-addpackage-07.png -------------------------------------------------------------------------------- /Images/graph-persona-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Images/graph-persona-01.png -------------------------------------------------------------------------------- /Images/graph-persona-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Images/graph-persona-02.png -------------------------------------------------------------------------------- /Images/graph-persona-03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Images/graph-persona-03.png -------------------------------------------------------------------------------- /Images/graph-test-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Images/graph-test-01.png -------------------------------------------------------------------------------- /Images/http-client-test-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Images/http-client-test-01.png -------------------------------------------------------------------------------- /Images/http-client-test-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Images/http-client-test-02.png -------------------------------------------------------------------------------- /Images/http-client-test-03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Images/http-client-test-03.png -------------------------------------------------------------------------------- /Images/spo-admin-portal-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Images/spo-admin-portal-01.png -------------------------------------------------------------------------------- /Images/spo-admin-portal-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Images/spo-admin-portal-02.png -------------------------------------------------------------------------------- /Images/spo-admin-portal-03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Images/spo-admin-portal-03.png -------------------------------------------------------------------------------- /Images/spo-admin-portal-04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Images/spo-admin-portal-04.png -------------------------------------------------------------------------------- /Images/tenant-app-catalog-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Images/tenant-app-catalog-01.png -------------------------------------------------------------------------------- /Images/tenant-app-catalog-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SharePoint/sp-dev-training-spfx-graph-3rdpartyapis/e7e625ec1d933a7ef7a2c3026a8b22ad286b0680/Images/tenant-app-catalog-02.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. All rights reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Microsoft SharePoint Framework Training Module - Leverage Microsoft Graph & third-party APIs 2 | 3 | This module will introduce you to utilizing external APIs in your SharePoint Framework projects. 4 | 5 | > This module is also published as a Microsoft Learn module: [Leverage Microsoft Graph & third-party APIs](https://learn.microsoft.com/training/modules/sharepoint-spfx-graph-3rd-party-apis) 6 | 7 | ## Lab - Leverage Microsoft Graph & third-party APIs 8 | 9 | The lab for this module is available in multiple units within the associated Microsoft Learn module. Use the following links to jump to the specific unit. Each Microsoft Learn unit represents a different lab exercise & demo in the presentation. 10 | 11 | - [Exercise - Call anonymous third-party REST APIs](https://learn.microsoft.com/training/modules/sharepoint-spfx-graph-3rd-party-apis/3-exercise-anonymous-apis) 12 | 13 | In this exercise, you'll create a new SharePoint Framework project with a single client-side web part that uses React to display the results from a call to an anonymous third-party API: the NASA Image REST API. 14 | 15 | - [Exercise - Call Azure AD secured REST APIs](https://learn.microsoft.com/training/modules/sharepoint-spfx-graph-3rd-party-apis/5-exercise-azure-ad-apis) 16 | 17 | In this exercise, you'll create a new SharePoint Framework project with a single client-side web part that uses React and Microsoft Graph to display users in the currently logged in user's directory. You'll use the Azure AD HTTP client API included in the SharePoint Framework to authenticate and call the Microsoft Graph REST API. 18 | 19 | - [Exercise - Call Microsoft Graph from SharePoint Framework components](https://learn.microsoft.com/training/modules/sharepoint-spfx-graph-3rd-party-apis/7-exercise-graph-api) 20 | 21 | In this exercise, you'll create a new SharePoint Framework project with a single client-side web part that uses React and Microsoft Graph to display the currently logged in user's personal details in a familiar office Persona card. 22 | 23 | ## Demos 24 | 25 | - [Call anonymous third-party REST APIs](./Demos/01-httpclient) 26 | - [Call Azure AD secured REST APIs](./Demos/02-aadhttpclient) 27 | - [Call Microsoft Graph from SharePoint Framework components](./Demos/03-msgraphclient) 28 | 29 | ## Watch the Module - Video 30 | 31 | This module has been recorded and is available in the SharePoint Development YouTube channel: [SharePoint Framework Training - Developing with the SharePoint Framework: Leverage Microsoft Graph & third-party APIs](https://www.youtube.com/watch?v=0zVtDn0ckBM&list=PLR9nK3mnD-OV-RPXQ3Lco845qoEy7VJoc) 32 | 33 | ## Contributors 34 | 35 | | Roles | Author(s) | 36 | | -------------------- | -------------------------------------------------------------------------------------------------------------- | 37 | | Lab Manuals / Slides | Andrew Connell (Microsoft MVP, [Voitanos](//github.com/voitanos)) [@andrewconnell](//github.com/andrewconnell) | 38 | | QA | Rob Windsor (Microsoft MVP) [@rob-windsor](//github.com/rob-windsor) | 39 | | Sponsor / Support | Vesa Juvonen (Microsoft) [@VesaJuvonen](//github.com/VesaJuvonen) | 40 | 41 | ## Version history 42 | 43 | | Version | Date | Comments | 44 | | ------- | ------------------ | -------------------------------------------------- | 45 | | 1.19 | December 13, 2024 | FY2025Q2 content refresh; update to SPFx v1.20.0 | 46 | | 1.18 | June 14, 2024 | FY2024Q4 content refresh; update to SPFx v1.19.0 | 47 | | 1.17 | May 5, 2023 | FY2023Q4 content refresh; update to SPFx v1.17.1 | 48 | | 1.16 | February 27, 2023 | FY2023Q3 content refresh; update to SPFx v1.16.1 | 49 | | 1.15 | December 5, 2022 | FY2023Q2 content refresh | 50 | | 1.14 | September 5, 2022 | FY2023Q1 content refresh; update to SPFx v1.15.2 | 51 | | 1.13 | May 2, 2022 | FY2022Q4 content refresh; update to SPFx v1.14 | 52 | | 1.12 | March 7, 2022 | FY2022Q3 content refresh | 53 | | 1.11 | December 8, 2021 | FY2022Q2 content refresh; retire local workbench | 54 | | 1.10 | September 13, 2021 | FY2022Q1 content refresh | 55 | | 1.9 | June 17, 2021 | FY2021Q4 content refresh | 56 | | 1.8 | March 6, 2021 | FY2021Q3 content refresh | 57 | | 1.7 | November 30, 2020 | FY2021Q2 content refresh | 58 | | 1.6 | August 31, 2020 | FY2021Q1 content refresh | 59 | | 1.5 | March 10, 2020 | FY2020Q3 content refresh & port module to MS Learn | 60 | | 1.4 | December 6, 2019 | FY2020Q2 content refresh | 61 | | 1.3 | September 2, 2019 | FY2020Q1 content refresh | 62 | | 1.2 | March 11, 2019 | FY2019Q3 content refresh | 63 | | 1.1 | January 17, 2019 | Slide updates, added screencast link to readme | 64 | | 1.0 | December 17, 2018 | Initial release | 65 | 66 | ## Disclaimer 67 | 68 | **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.** 69 | 70 | ## Contributing 71 | 72 | This project welcomes contributions and suggestions. Most contributions require you to agree to a 73 | Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us 74 | the rights to use your contribution. For details, visit https://cla.microsoft.com. 75 | 76 | When you submit a pull request, a CLA-bot will automatically determine whether you need to provide 77 | a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions 78 | provided by the bot. You will only need to do this once across all repos using our CLA. 79 | 80 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 81 | For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or 82 | contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. 83 | 84 | 85 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). 6 | 7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report). 14 | 15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey). 16 | 17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc). 18 | 19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how an attacker might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd). 40 | 41 | 42 | --------------------------------------------------------------------------------