OAuth2 uses Faraday to make HTTP requests. The Authorization in the Header is actually encoded using Base64. When we make requests using 3rd party tool such as Postman, this is not a issue.

Therefore, your consumer test should look like this:

apple_service.given(“the authnz provider is up”).
upon_receiving(“a post token”).
with(method: :post, path: ‘/token’,
headers: {‘Content-Type’ => ‘application/x-www-form-urlencoded’, ‘Authorization’           =>’Basic ‘ + Base64.encode64(Rails.configuration.clientid + ‘:’ +                Rails.configuration.clientsecret).delete(“\n”)},
body: { ‘scope’ => Rails.configuration.scope, ‘grant_type’=>’client_credentials’}
).
will_respond_with(
status: 200,