本文介绍了如何在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中传递身份验证凭据
发布评论