Skip to content

Oauth2 not supported. #96

@jabberwocky-rs

Description

@jabberwocky-rs

Since Microsoft and Gmail are requiring Oauth2 authentication, it would make sense to allow that in this package. The user would be required to obtain the authentication token and pass it as the password. The following code works for office365:

	/// <summary>
	/// Authenticates a user towards the POP server using the Oauth2 commands
	/// </summary>
	/// <param name="username">The username</param>
	/// <param name="password">The Oauth2 token</param>
	/// <exception cref="PopServerException">If the server responded with -ERR</exception>
	private void AuthenticateUsingOauth2(string username, string password)
	{
		string auth = "user=" + username + "\u0001auth=Bearer " + password + "\u0001\u0001";
		string authToken = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(auth));
		SendCommand("AUTH XOAUTH2"); // + password);
		SendCommand(authToken);

		// Authentication was successful if no exceptions thrown before getting here
	}

I just added a new Oauth2 authentication type. Unfortunately, it looks like Gmail has a slightly different syntax, so you might need a separate type for it.

This is not a bug, but it would extend the usefulness of OpenPop as email security becomes tighter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions