Matthew
Matthew

Reputation: 604

Can a user update their own Azure B2C account details via the Graph API?

I have a ReactJS application that uses Azure B2C for user sign up / sign in functionality. I want to be able to read / update the users data that is stored in B2C via the Microsoft Graph API.

What I've done so far is request an access token for the signed in user via acquireTokenSilent which successfully returns a jwt token. However when calling the Graph API I get a 401 Access token validation failure. Invalid audience

function requestProfile() {
        instance.acquireTokenSilent({
            scopes: ["offline_access"],
            account: accounts[0]
        }).then((response) => {
            const token = response.idToken;
            console.log(token);
            callMsGraph(token, "GET", "https://graph.windows.net/v1.0/me").then(response => {
                setGraphData(response.data);
                console.log(response.data);
            });
        });
    }

Is this even possible?

Upvotes: 0

Views: 512

Answers (1)

Jas Suri - MSFT
Jas Suri - MSFT

Reputation: 11335

No it’s not possible. Either use client credential flow and have your server call graph api on the users behalf, or use the profile edit user flow.

Upvotes: 2

Related Questions