Coder Social home page Coder Social logo

Getting `MangoPay::ResponseError: The authorization credentials are not valid` after running several tests about mangopay2-ruby-sdk HOT 7 CLOSED

jfloff avatar jfloff commented on August 15, 2024 1
Getting `MangoPay::ResponseError: The authorization credentials are not valid` after running several tests

from mangopay2-ruby-sdk.

Comments (7)

mickaelpois avatar mickaelpois commented on August 15, 2024

@jfloff Are you always facing this issue ?
Could you give us more details on this (requests and responses, execution time) ?

from mangopay2-ruby-sdk.

jfloff avatar jfloff commented on August 15, 2024

I haven't done this in a while because I started using VCR gem for my specs, but if I force new requests I'm still facing that. The pattern is what I described above, it works fine then after multiple specs running it stops workings and returns that error. To me it seems a throttling issue, but the error message does not match that.

from mangopay2-ruby-sdk.

SoloJr avatar SoloJr commented on August 15, 2024

Hi @jfloff

As many times as I ran the tests, not even once I got an error...

from mangopay2-ruby-sdk.

jfloff avatar jfloff commented on August 15, 2024

I will try to get a full log the next time I can replicate this issue. We can close for now and reopen when I get that log.

from mangopay2-ruby-sdk.

jfloff avatar jfloff commented on August 15, 2024

Yesterday running tests I found the error yet again:

Failure/Error:
       mangopay_operation = MangoPay::NaturalUser.create({
         Email: self.email,
         FirstName: self.first_name,
         LastName: self.last_name,
         Address: address,
         Birthday: self.birth_date.to_time.to_i,
         Nationality: self.country,
         CountryOfResidence: address[:Country],
       })

     MangoPay::ResponseError:
       The authorization credentials are not valid
     # /app/heroku/ruby/bundle/ruby/2.6.6/gems/mangopay-3.0.32/lib/mangopay.rb:148:in `request'
     # /app/heroku/ruby/bundle/ruby/2.6.6/gems/mangopay-3.0.32/lib/mangopay/http_calls.rb:13:in `create'
     # ./app/models/user.rb:709:in `block in mangopay_create_natural_user'

EDIT

This was the VCR that got recorded today when I faced this issue yet again:

- request:
    method: post
    uri: https://api.sandbox.mangopay.com/v2.01/<REDACTED>/wallets
    body:
      encoding: UTF-8
      string: '{"Owners":[83945627],"Description":"owner wallet for user [email protected]","Currency":"EUR"}'
    headers:
      User-Agent:
      - MANGOPAY V2 RubyBindings/3.0.32
      Authorization:
      - bearer <REDACTED>
      Content-Type:
      - application/json
      X-Mangopay-Client-User-Agent:
      - '{"bindings_version":"3.0.32","lang":"ruby","lang_version":"2.6.6 p146 (2020-03-31)","platform":"x86_64-linux","uname":"Linux
        d76f32f75be0 4.19.0-8-amd64 #1 SMP Debian 4.19.98-1 (2020-01-26) x86_64 x86_64
        x86_64 GNU/Linux"}'
      Accept-Encoding:
      - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
      Accept:
      - "*/*"
  response:
    status:
      code: 401
      message: Unauthorized
    headers:
      Date:
      - Mon, 13 Jul 2020 10:56:53 GMT
      Content-Type:
      - application/json; charset=utf-8
      Content-Length:
      - '175'
      Connection:
      - keep-alive
      Set-Cookie:
      - __cfduid=d9dc1d231712140d0c77d6bd88edd371e1594637813; expires=Wed, 12-Aug-20
        10:56:53 GMT; path=/; domain=.mangopay.com; HttpOnly; SameSite=Lax
      Cache-Control:
      - no-cache
      Pragma:
      - no-cache
      Expires:
      - "-1"
      Www-Authenticate:
      - Basic realm=MangopayAuthentication
      - Bearer
      - Bearer realm="MangopayAuthentication"
      Cf-Cache-Status:
      - DYNAMIC
      Cf-Request-Id:
      - 03e96b20630000da8246b0f200000001
      Expect-Ct:
      - max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
      Server:
      - cloudflare
      Cf-Ray:
      - 5b227ae09b5bda82-LIS
    body:
      encoding: UTF-8
      string: '{"Message":"The authorization credentials are not valid","Type":"invalid_credentials","Id":"a8e5bb05-5517-436f-af75-9da7212f1b75#1594637813","Date":1594637814.0,"errors":null}'
    http_version: null
  recorded_at: Mon, 13 Jul 2020 10:56:53 GMT

from mangopay2-ruby-sdk.

jfloff avatar jfloff commented on August 15, 2024

I've updated the previous message with the VCR I recorded on my tests with this exact problem

from mangopay2-ruby-sdk.

jfloff avatar jfloff commented on August 15, 2024

For future reference this is due to MGP oauth/token request. What happens is that on a first run VCR records the oauth/token request. But when you record new episodes at a later date (VCR=new_episodes) that token is expired, and since that token is replayed by VCR you get an unauthorized reply.

As a solution, either reply the whole spec or manually remove the token request from your VCR tape and record let VCR record new episodes (hence recording both the new token and the new request)

from mangopay2-ruby-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.