cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
stiwari
Frequent Visitor

Unable to fetch user id after passing obtained access token of my sharepoint app in Microsoft flow

Went through these tutorials to assign item-level permissions using Flows:

https://noellawlor.wordpress.com/2018/01/18/setting-sharepoint-item-list-permissions-with-flow/

and a follw-up to 

https://powerusers.microsoft.com/t5/Using-Flows/Item-Level-Permissions-not-setting-in-sharepoint-onl...

 

I am unauthorized to fetch the user ID in flow. 

 

Here's what I did:

usernameclaim.PNG

 

get_user_id.PNG

 

After running the workflow:

unauthorized.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Unable to fetch user id after passing obtained access token of my sharepoint app in Microsoft flow

Hi @stiwari have you considered using the builtin "Sent HTTP Request to SharePoint" action? That way you won't have to worry about the oauth elements, you just need to get your REST call right. Happy to provide guidance on that action if you need any help.





Did my reply help? Please give it a thumbs up.
Did I answer your question? Please mark my post as a solution!
If you liked my response, please consider giving it a thumbs up. THANKS!


Proud to be a Flownaut!





Community Leader: Black Country PowerApps & Flow User Group

View solution in original post

5 REPLIES 5
Super User
Super User

Re: Unable to fetch user id after passing obtained access token of my sharepoint app in Microsoft flow

Have you tried running the call within Postman to see if you get the same result?





Did my reply help? Please give it a thumbs up.
Did I answer your question? Please mark my post as a solution!
If you liked my response, please consider giving it a thumbs up. THANKS!


Proud to be a Flownaut!





Community Leader: Black Country PowerApps & Flow User Group

stiwari
Frequent Visitor

Re: Unable to fetch user id after passing obtained access token of my sharepoint app in Microsoft flow

Postman says

{
"odata.error": {
"code": "-1, Microsoft.SharePoint.Client.InvalidClientQueryException",
"message": {
"lang": "en-US",
"value": "The query string \"loginName\" is missing or invalid."
}
}
}

 

What I read from Microsoft Flow docs, to get user id by REST API in flow, you have to pass your login name in this URL format:

https://<sharepoint-sitename>/_api/web/siteusers(@v)?@v=’<login-name>'

and various examples have used 'CreatedBy Claims' to get the <login-name>

stiwari
Frequent Visitor

Re: Unable to fetch user id after passing obtained access token of my sharepoint app in Microsoft flow

Here is one more good example following my question:

get_user_id.PNG

 

I replaced '' with %27 and am passing the encodeURIcomponent(variables['email']) value as a request parameter and still says 'Unauthorized'. I did the same thing in Postman and it fetched me the result. I don't what's going wrong. No way to debug and no way to see what's going wrong. Sharepoint Online is such a frustrating creation of Microsoft. I have been stuck into Item-Level permissions for 2 weeks and still 25% success. 

 

Also to let you know that I tried encoding UserClaims and passed the same way as I have asked in the original question but it's still unautorized.

Super User
Super User

Re: Unable to fetch user id after passing obtained access token of my sharepoint app in Microsoft flow

Hi @stiwari have you considered using the builtin "Sent HTTP Request to SharePoint" action? That way you won't have to worry about the oauth elements, you just need to get your REST call right. Happy to provide guidance on that action if you need any help.





Did my reply help? Please give it a thumbs up.
Did I answer your question? Please mark my post as a solution!
If you liked my response, please consider giving it a thumbs up. THANKS!


Proud to be a Flownaut!





Community Leader: Black Country PowerApps & Flow User Group

View solution in original post

stiwari
Frequent Visitor

Re: Unable to fetch user id after passing obtained access token of my sharepoint app in Microsoft flow

I didn't feel the need to use HTTP connector and try the Oauth steps. "Send HTTP Request to Sharepoint" does all that without prompting you for access tokens.

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Automate Community!

firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Users online (8,443)