I have SalesForce and SharePoint connected on OAuth. I have created Sharepoint app-only, added it to Custom Auth provider and created namedcredentials which is showing as authenticated. Every blog post is saying that named credentials would take care of Authentication. But in my case it is giving me null Authorization header in my rest callout.And the REST callout is failing. Do we need to still pass the access token by receiving the Auth code from the OAuth-Only Initialization URL(from custom auth provider)?
//string token= GetJWT(); If I use this it works fine
req.setHeader('Authorization', 'bearer ' + token);
Because for REST callout we get the type auth. code from Oauthorize.aspx page.