Adding Authentication Header to Request
See original GitHub issueTrying to stream media from an API that requires the header “Authorization: Bearer <token>”.
I’ve used the following to inject the header:
@Injectable()
export class ApiAuthInterceptor implements HttpInterceptor {
constructor( @Inject(forwardRef(() => SessionProvider)) private session: SessionProvider) { }
intercept(req: HttpRequest<any>, next: HttpHandler) {
let auth: any = {};
if (this.session.auth) auth = this.session.auth;
const newReq = req.clone({ headers: req.headers.set('Authorization', 'Bearer ' + auth.access_token) });
return next.handle(newReq);
}
};
@NgModule({
providers: [
ApiProvider,
{ provide: HTTP_INTERCEPTORS, useClass: ApiAuthInterceptor, multi: true }
]
})
This works great for images, and video will load and play, but the file appears to download in its entirety and play. Also the video time is listed at --:-- and the seek control slider is disabled.
If I disable all authentication on the API and streamed the same file it worked normally, buffering, seek, etc.
Is there a proper way to add the “Authentication” header to the stream request?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
Top Results From Across the Web
Authorization - HTTP - MDN Web Docs - Mozilla
The HTTP Authorization request header can be used to provide credentials that authenticate a user agent with a server, allowing access to a ......
Read more >Setting Authorization Header of HttpClient - Stack Overflow
What I've used is: client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", "encrypted user/pwd"); Taking encrypted user/pwd from ...
Read more >How do I Send a GET Request with Bearer Token ... - ReqBin
To send a GET request with a Bearer Token authorization header, you need to make an HTTP GET request and provide your Bearer...
Read more >Make authenticated requests - Flutter documentation
Add authorization headers The http package provides a convenient way to add headers to your requests. Alternatively, use the HttpHeaders class from...
Read more >Authorizing requests - Postman Learning Center
You can include the auth details either in the request headers or in the body / URL. Select one from the Add authorization...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Would be a very usefull feature.
https://github.com/nchutchind/cordova-plugin-streaming-media/pull/229