我试图在.NET Core控制台/桌面应用程序(不是ASP.NET Core)中通过Outlook.com/Hotmail.com/Live.com的IMAP服务器获取OAuth2令牌以执行XOAUTH2身份验证。
以前,我对DotNetOpenAuth库(例如,在控制台.NET应用程序中)进行了相同的操作:
public class Toot extends Canvas {
private static final long serialVersionUID = 1L;
public static int xPos, yPos, yV, xV;
public static void main(String[] args) throws InterruptedException {
Random rand = new Random();
JFrame frame = new JFrame("My Drawing");
Canvas canvas = new Toot();
canvas.setSize(400, 400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
frame.add(canvas);
frame.pack();
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
canvas.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
xV = rand.nextInt(5) + 1;
yV = rand.nextInt(5) + 1;
}
});
xPos = rand.nextInt(400);
yPos = rand.nextInt(400);
xV = rand.nextInt(5) + 1;
yV = rand.nextInt(5) + 1;
new javax.swing.Timer(1000/60,e->canvas.repaint()).start();
}
@Override
public void paint(Graphics g) {
Random rand = new Random();
if (xPos < 0) {
xV += rand.nextInt(2) - 1;
xV = Math.abs(xV);
}
if (yPos < 0) {
yV += rand.nextInt(2) - 1;
yV = Math.abs(yV);
}
if (xPos > 400) {
xV += rand.nextInt(2) - 1;
xV = - Math.abs(xV);
}
if (yPos > 400) {
yV += rand.nextInt(2) - 1;
yV = - Math.abs(yV);
}
xPos +=xV;
yPos +=yV;
g.fillOval(xPos, yPos, 6, 6);
}
}
但是DotNetOpenAuth从未移植到.NET Core平台。如何使用.NET Core 2.0控制台或.NET Core 3.0桌面应用程序实现相同的目的?我在OAuth 2.0上发现的所有内容都只与ASP.NET Core(而不是台式机/控制台)或Google提供程序有关(而我需要Microsoft提供程序)。