【发布时间】:2022-01-30 00:41:50
【问题描述】:
我正在处理一个从 Azure Blob 存储下载图像的 Android 项目,并且收到响应代码 400 Authorization Header not valid。
URL url = new URL(src);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.setConnectTimeout(15000);
connection.setReadTimeout(15000);
connection.setRequestMethod("GET");
Date date = new Date();
connection.setRequestProperty("Authorization","SAS Signature here?");
connection.setRequestProperty("x-ms-date", date.toString());
connection.setRequestProperty("x-ms-version", "2021-02-12");
connection.connect();
int response = connection.getResponseCode();
Log.e("Response Code:",String.valueOf(response));
Log.e("Response Message:",connection.getResponseMessage());
InputStream input = connection.getInputStream();
myBitmap = BitmapFactory.decodeStream(input);
Log.e("Bitmap","returned");
【问题讨论】:
标签: java android azure rest authentication