如何在VBA中传递身份验证凭据

编程入门 行业动态 更新时间:2024-10-25 22:30:44
本文介绍了如何在VBA中传递身份验证凭据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试编写一个VBA宏,该宏将通过我的邮件地址并获取一些内容(JIRA的REST API),但是将我的代码从java转换为VBA有一些困难。目前,这是我的java代码:

I'm trying to write a VBA macro that would pass my credentails to an address and fetch some content (REST API for JIRA), but I'm having some difficulties converting my code from java to VBA. Currently, this is my java code:

String username = "myUser"; String password = "myPassword"; String authString = username + ":" + password; byte[] authEncBytes = Base64.encodeBase64(authString.getBytes()); String authStringEnc = new String(authEncBytes); System.out.println("Base64 encoded auth string: " + authStringEnc); URL url = new URL(address); URLConnection urlConnection = url.openConnection(); urlConnection.setRequestProperty("Authorization", "Basic " + authStringEnc); InputStream is = urlConnection.getInputStream(); InputStreamReader isr = new InputStreamReader(is);

我正在尝试将其转换为VBA,我不完全确定如何处理它,或者如果有一些图书馆会促进这一点。

And I'm trying to convert this to VBA, I'm not entirely sure how to handle it, or if there's some library that would facilitate this.

推荐答案

对于基本身份验证,您可以简单地:

For Basic Authentication you can simply:

Dim response As String With CreateObject("Microsoft.XMLHTTP") .Open "GET", address, false, username, password .Send response = .responseText End With Msgbox response

更多推荐

如何在VBA中传递身份验证凭据

本文发布于:2023-11-17 05:53:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609062.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:凭据   身份验证   如何在   VBA

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!