botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

How to get Authenticated User Email address through Azure Ad , I am using bot framework , C# and for authentication i am using AuthBot .

Open Masssluis opened this issue 10 years ago • 5 comments

@matvelloso @msftgits PLEASE HELP!

Masssluis avatar Oct 21 '16 11:10 Masssluis

Is there any way to get the user email id , as we are getting the user username using the AuthBot. @matvelloso

Masssluis avatar Oct 21 '16 12:10 Masssluis

the from.id should be the email address and the from.name should be the name from the sender field of the email, getting information from active directory is probably an exercise with this api https://graph.microsoft.io/en-us/

tomlm avatar Nov 03 '16 23:11 tomlm

Yes but that might not be reliable information depending on the channel. What you really want is to rely on the token from the AuthBot to find that information. Look at how we read the authresult here: https://github.com/MicrosoftDX/AuthBot/blob/master/AuthBot/Dialogs/AzureAuthDialog.cs#L44 and then get the username here: https://github.com/MicrosoftDX/AuthBot/blob/master/AuthBot/Dialogs/AzureAuthDialog.cs#L52

Basically all that info is in the token returned. If you take the token and isolate the value between the first "." and the last ".", what's in there is a Base64 encoded JSON. If you base64 decode it, you will see all this data, name , e-mail, etc. Beyond that, you can also request a token for the graph like Tom said and ask for additional info, like who manages who, etc.

matvelloso avatar Nov 04 '16 03:11 matvelloso

More on that discussed here: https://github.com/MicrosoftDX/AuthBot/issues/2

matvelloso avatar Nov 04 '16 03:11 matvelloso

Even this help me . Really thanks a lot

shivani123singh avatar Feb 20 '20 02:02 shivani123singh