Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

msGraph - post|update requests #41

Open
m0jimo opened this issue Oct 29, 2020 · 2 comments
Open

msGraph - post|update requests #41

m0jimo opened this issue Oct 29, 2020 · 2 comments

Comments

@m0jimo
Copy link

m0jimo commented Oct 29, 2020

$msal works great for me with Graph connections to get data from Sharepoint.

But is there a way how to send a Graph post request or at least to use client for Graph post and update request?

Thanks.

@jadjare
Copy link

jadjare commented Dec 2, 2020

I ran into the same problem and overcome it by making a my own post request, in my case by using the Axios library.

I needed to check if a user was a member of a group and achieved this using the onToken callback parameter.

Below is a simplified example

Vue.use(msal,
    {
        
        auth: {
            authority: `https://login.microsoftonline.com/${process.env.VUE_APP_AZURE_ACTIVE_DIRECTORY_TENANT_ID}`,
            clientId: process.env.VUE_APP_AZURE_STORE_CLIENT_APPLICATION_ID,
            redirectUri: `${window.location.origin}/login`,

            onToken: (ctx) => {
                        const groupIds = {groupIds: []}//Group Id's retrieved from config
                        axios.post(`https://graph.microsoft.com/v1.0/directoryObjects/${ctx.account.accountIdentifier}/checkMemberGroups`,
                            { groupIds },
                            { headers: {
                                authorization: `bearer ${ctx.data.accessToken}`,
                                "access-control-allow-methods": "[POST]",
                                Accept: "application/json",
                                "Content-Type": "application/json"
                            }
                            }).then(response => {
                                const groups = response.data.value;
                                //Add the groups to the user stored in Vuex
                            });
                    }
                }
            })

@l3miage-serzhann
Copy link

$msal works great for me with Graph connections to get data from Sharepoint.

But is there a way how to send a Graph post request or at least to use client for Graph post and update request?

Thanks.

Actually you can add the configurations in your request .Like this:
$msal.msGraph({url:'https://graph.microsoft.com/v1.0/me/events',method:'POST',data:getters.getItem}) I use Vuex store here ,dont be confused

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants