“Authentication not in correct format” when setting Azure Blob Service Properties (REST API)

前端 未结 3 1224
死守一世寂寞
死守一世寂寞 2021-01-20 23:43

I am trying to set CORS rules on my Azure Blob Storage account by following these instructions.

This is the error I receive after making my request:

相关标签:
3条回答
  • 2021-01-21 00:11

    For people reaching this page and wondering why you get this error even though you are using a Shared Access Signature URL, then you most likely are sending YOUR APP token to Azure. Make sure to NOT include the Authorization header in this case.

    0 讨论(0)
  • 2021-01-21 00:17

    The request has an incomplete Authorization header. It needs to contain the authentication scheme, storage account name, and signature. For example;

    Authorization: SharedKey myaccount:Z1lTLDwtq5o1UYQluucdsXk6/iB7YxEu0m6VofAEkUE=
    

    For more information, see Authentication for the Windows Azure Storage Services. On the other hand, if you use one of the Windows Azure Storage Client Libraries, it will handle the authentication for you. For .NET library, please see our NuGet package.

    0 讨论(0)
  • 2021-01-21 00:23

    Following what @jsgoupil said:

    For people reaching this page and wondering why you get this error even though you are using a Shared Access Signature URL, then you most likely are sending YOUR APP token to Azure. Make sure to NOT include the Authorization header in this case.

    In case you have an interceptor you can add a skip to a request by following the instructions on this stackOverflow post: https://stackoverflow.com/a/49047764/5232022

    export const InterceptorSkipHeader = 'X-Skip-Interceptor'; // <-- ADD THIS
    
    @Injectable()
    export class SkippableInterceptor implements HttpInterceptor {
    
      intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
        // Add the following if to your interceptor
        if (req.headers.has(InterceptorSkipHeader)) {
          const headers = req.headers.delete(InterceptorSkipHeader);
          return next.handle(req.clone({ headers }));
        }
    
        ...  // intercept
      }
    
    }
    

    Then whenever you want to skip the interception for a particular request:

    const headers = new HttpHeaders().set(InterceptorSkipHeader, ''); // <-- this will skip it
    
    this.httpClient.get<ResponseType>(someUrl, { headers }) // <-- dont forget to add it here as well
    
    0 讨论(0)
提交回复
热议问题