获取Azure私有Blob

时间:2019-07-18 17:29:30

标签: azure angular5 blob token azure-storage-blobs

我正在尝试通过API访问天蓝色blob

我正在使用图书馆https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-angular/samples/MSALAngularDemoApp

在app.module中添加了配置:

MsalModule.forRoot({
  clientID: 'myClientId',
  authority: "https://login.microsoftonline.com/myClientId",
  redirectUri: "http://localhost:4300/",
  validateAuthority : true,
  cacheLocation : "localStorage",
  postLogoutRedirectUri: "http://localhost:4300/",
  navigateToLoginRequestUrl : true,
  popUp: true,
  logger :loggerCallback,
  correlationId: '1234',
  piiLoggingEnabled: true,
  unprotectedResources: ["https://www.microsoft.com/en-us/"],
});

在app.component中获得令牌

login() {
 this.authService.loginPopup(["https://graph.microsoft.com/.default"]);
} // I'm not for sure that scope is correct

我正在尝试在服务中获取Blob(我的Blob是私有的):

httpGetRequest() {
const token = JSON.parse(sessionStorage.getItem('authToken'));
const headers = new Headers({ 
  'x-ms-version': '2018-03-28', 
  'x-ms-date': (new Date()).toUTCString(),
  'Authorization': 'Bearer' + token,
 });
return this.http.get(this.url, new RequestOptions({headers: headers})).map((response: Response) => response.json());
}

我遇到403错误。

0 个答案:

没有答案