Skip to content

Invalid scopes (using the example code from README) #889

Closed

Description

Describe the bug

I'm trying to follow the examples in the README, but my scope definitions seem to be wrong, I'm just getting this error:

Microsoft Entra ID error '(invalid_scope) AADSTS1002012: The provided value for scope User.Read is not valid.

Expected behavior

code in the README should execute successfully

How to reproduce

credentials = ClientSecretCredential(
    os.getenv("AZURE_TENANT_ID"),
    os.getenv("AZURE_CLIENT_ID"),
    os.getenv("AZURE_CLIENT_SECRET"),
)

scopes = ["User.Read"]
client = GraphServiceClient(credentials=credentials, scopes=scopes)

await client.users.by_user_id('userPrincipalName').get()

SDK Version

1.5.3

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_

Activity

  1. added
    status:waiting-for-triage
    type:bug
    on Sep 5, 2024
  2. andrueastman commented on Sep 6, 2024

    @andrueastman
    Contributor

    Thanks for raising this Francisco Schulz (@fschlz)

    Apologies, the scope for that snippet is incorrect. Authored #890 to resolve this.

    As you the sample is using the ClientSecretCredential the application is using app only access so the scope should be the default scope of 'https://graph.microsoft.com/.default' and then configured on the app portal.

    https://learn.microsoft.com/en-us/graph/permissions-overview?tabs=http#application-permissions

  3. added
    type:documentation
    and removed
    status:waiting-for-triage
    on Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    WIPtype:bugtype:documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions