Skip to content

ClientConfigurationError: Scopes are required to obtain an access token #193

@bitflower

Description

@bitflower

Bug Report

Prerequisites

  • Can you reproduce the problem?
  • Are you running the latest version?
  • Are you reporting to the correct repository?
  • Did you perform a cursory search?

Description

I'm getting the given error although setting the scopes:

const graphScopes = ['User.Read', 'Mail.Send']; 
getAuthProvider(msalInstance, graphScopes);

...

import * as MSALAuthenticationProvider from '@microsoft/microsoft-graph-client/lib/es/browser/MSALAuthenticationProvider';
export const getAuthProvider = (userAgentApplication, scopes) => {
  console.log('getAuthProvider');
  authProvider = new MSALAuthenticationProvider.MSALAuthenticationProvider(
    userAgentApplication,
    scopes
  );
};

...

import * as EsClient from '@microsoft/microsoft-graph-client/lib/es/Client';
export const getGraphCLient = (): EsClient.Client => {
  console.log('getGraphCLient');

  const options: ClientOptions = {
    authProvider
  };
  //   const Client = Client.Client;
  graphClient = EsClient.Client.initWithMiddleware(options);

  return graphClient;
};

...

    try {
      let userDetails = await graphClient.api('/me').get();
      console.log(userDetails);
    } catch (error) {
      throw error;
    }

Console Errors: [Is there any console error]

app-root.entry.js:7685 Uncaught (in promise) 
GraphError {statusCode: -1, code: "Error", message: "ClientConfigurationError: Scopes are required to obtain an access token. Given value: undefined", requestId: null, date: Tue Jun 18 2019 11:06:15 GMT+0200 (Mitteleuropäische Sommerzeit), …}
body: "Error: ClientConfigurationError: Scopes are required to obtain an access token. Given value: undefined"
code: "Error"
date: Tue Jun 18 2019 11:06:15 GMT+0200 (Mitteleuropäische Sommerzeit) {}
message: "ClientConfigurationError: Scopes are required to obtain an access token. Given value: undefined"
requestId: null
statusCode: -1

Screenshots: [If applicable, add screenshots to help explain your problem]
Bildschirmfoto 2019-06-18 um 11 10 55

Expected behavior: [What you expected to happen]
Can use the graph client as expected.

Repo to re-produce

https://github.com/bitflower/stencil-ms-graph

Additional context

This is inside astencil app bundled up with rollup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions