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

Using AppPassword for an authentication to outlook.office365.com mail box in .NET #25968

Closed
bastyuchenko opened this issue Feb 28, 2019 — with docs.microsoft.com · 6 comments
Assignees
Labels
active-directory/svc cxp in-progress product-question Sample-Needed Tag signifying that Sample is not available or existing one requires modification triaged

Comments

Copy link

I generated AppPassword for my account and want to acquire an access token to authenticate to my mailbox in outlook.office365.com. I tried to use the following code
var _authContext = new AuthenticationContext(authorityFormatString);
_authContext.AcquireTokenAsync("https://graph.windows.net", clientID, new UserPasswordCredential(emailAdress, emailPassword));
It does not work - I receive "Invalid username or password.".

Is it possible to use AppPassword in .NET code?
Could you give me an example of code or a reference to an article with a code example?


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@shashishailaj shashishailaj self-assigned this Mar 1, 2019
@shashishailaj shashishailaj added triaged cxp product-question Sample-Needed Tag signifying that Sample is not available or existing one requires modification and removed product-question labels Mar 1, 2019
@shashishailaj
Copy link
Member

@bastyuchenko Thank you for your feedback . We will investigate and update the thread accordingly.

@MohitDhingra-MSFT
Copy link

MohitDhingra-MSFT commented Mar 5, 2019

@bastyuchenko

I have tried to use UserPasswordCredential in one of my sample application and I found that if we register our app as (web app or web api), we can not authenticate with username and password.
But if we register our app as a native client, we can get the access token.

I am not sure if App password can be used this way. App passwords were only created for use with our legacy apps (outlook etc. ) which did not support Modern authentication and could not thus use MFA flow. However I tested it with normal username/password combination. I assume that you already have a application registered through which you are trying out the provided code snippet? We could not find any specific code sample which could suffice your use case as described.

Could you please use clientID as a native app client id and let us know if it helps?

@shashishailaj
Copy link
Member

@bastyuchenko Could you please let us know if explanation suggested above worked for you ?

@bastyuchenko
Copy link
Author

@shashishailaj
No, the explanation is about nothing. As I understood that @MohitDhingra-MSFT is not sure and doesn't know is it possible to do in code or not. I have used user and password and it does not work because of MFA. As I understood AppPassword was created to avoid MFA and it's possible to do in Microsoft applications like outlook but I haven't found any proof that it is possible in my custom .NET application. My question is about it.

@shashishailaj
Copy link
Member

@bastyuchenko Thank you for quick response. We apologize that the provided information was not useful to you . But app passwords were designed to serve as second factor for Microsoft legacy applications which could not work with MFA as per my knowledge and hence it may not be possible to use in your custom .NET code.

@shashishailaj
Copy link
Member

@bastyuchenko We will close this issue now . Should you have any further queries on this , please tag me to your reply and we can engage in a conversation again .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
active-directory/svc cxp in-progress product-question Sample-Needed Tag signifying that Sample is not available or existing one requires modification triaged
Projects
None yet
Development

No branches or pull requests

6 participants