FOSOAuthServerBundle: Embed the access_token in the Authorization header FOSOAuthServerBundle: Embed the access_token in the Authorization header symfony symfony

FOSOAuthServerBundle: Embed the access_token in the Authorization header


As mentioned here by @alanbem, the Authorization Header should look like this:

Authorization: Bearer N2FmNzhhNGM2MTI5N2JhMWJlYj...

Note: If you're using AFHTTPClient for iOS development, you simply have to override the (void)setAuthorizationHeaderWithToken:(NSString *)token method.

- (void)setAuthorizationHeaderWithToken:(NSString *)token {    [self setDefaultHeader:@"Authorization" value:[NSString stringWithFormat:@"Bearer %@", token]];}


As mentioned by @Mick, you can use the Authorization header.

If you are doing it internally, inside PHPUnit and any other place that uses a Symfony Request, you should use the header like:

$headers = ['HTTP_AUTHORIZATION' => 'Bearer  2FmNzhhNGM2MTI5N2JhMWJlYj...'];

It's important when you are testing and don't want to mess your URI or Request params.