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

前端 未结 3 1225
死守一世寂寞
死守一世寂寞 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: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, next: HttpHandler): Observable> {
        // 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(someUrl, { headers }) // <-- dont forget to add it here as well
    

提交回复
热议问题