Hi there i'm using pactflow on a provider ruby on ...
# pactflow
n
Hi there i'm using pactflow on a provider ruby on rails application and on the verification step i am getting a 401 unauthorized error. See error below:
Error retrieving <https://applyboard>.<name>.io status=401 Unauthorized. Please see <https://docs.pactflow.io/docs/login-help> for more information. (Pact::Error)
I have already followed the steps outlined here: https://docs.pactflow.io/docs/login-help/#getting-a-401-unauthorized-when-publishing-or-verifying-pacts Package should be up to date, i'm using pact gem version 1.32. Using the read/write token from pactflow. And I followed the provider code in pact_helper.spec here: https://docs.pactflow.io/#configuring-your-api-token
m
Can you please set log level to debug (or verbose to true) and share a redacted version to us?
n
Hey, yeah for sure here it is.
m
Interesting. I can’t see any
Authorization: Bearer xyz
header in there
Can you please show a little more about your Ruby code setup?
n
Oh do I need to somehow manually add that Authorization header?? Let me try to get you some more information.
m
no, it should be set automatically if the token is correctly set
I don’t know the Ruby implementation all that well and why it’s not working though
n
Here is a little more information, we using ruby on rails with a rails version of 4.2. I have pact in the Gemfile.Lock with a version of 1.32.0. I'm using the regular
bundle exec rake pact:verify
to try and verify pacts. In the Rakefile i've added :
require 'pact/tasks'
My pact_helper.rb file looks like:
Copy code
require 'pact/provider/rspec'

require "./spec/pact/provider_states_for_order_item_categories"

Pact.service_provider "monolith" do
  app_version "7c264ed3c871a8d34e7f9e56cd18aec441e0be06"
  publish_verification_results 'true'
  honours_pacts_from_pact_broker  do
    verbose true
    pact_broker_base_url "https://<ORG>.<http://pactflow.io|pactflow.io>", { token: "<READ/WRITE TOKEN>" }
  end
end
Then in the
spec/pact/provider_states_for_order_item_categories.rb
I have:
Copy code
equire "rails_helper"

Pact.provider_states_for "testDemo_platform_payment_service" do
  provider_state "All order item categories are present" do
    set_up do
      student = create(:student)
      sign_in student
    end
  end
end
m
OK, i’m pretty sure the issue is the version
You’re on a waaaaaaaay old one
That gem predates PactFlow, so it’s not surprising it doesn’t support token based auth! 😛
n
Ohhh loool okay I see, so could I try using a newer Gem then maybe? But would that work with such an old version of ruby on rails
👍 1
m
hmm that I couldn’t tell you, but I guess a
bundle update
will tell you how far off the mark you might be
b
It’s going to mostly depend what version of RSpec you’re running. It does not care about rails itself.
👍 2