Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Default UA Sent With Requests #2

Open
steveamaza opened this issue Apr 23, 2018 · 6 comments
Open

No Default UA Sent With Requests #2

steveamaza opened this issue Apr 23, 2018 · 6 comments

Comments

@steveamaza
Copy link

Sometimes, Cloudflare blocks API requests sent to Paystack servers that have no accompanying User Agent. Setting API requests with any User Agent resolves this.

My favourite UA is Chrome's (for no reason 😀 ) Mozilla/5.0 (Unknown; Linux) AppleWebKit/538.1 (KHTML, like Gecko) Chrome/v1.0.0 Safari/538.1

@Ajibola
Copy link
Contributor

Ajibola commented Apr 29, 2018

@steveamaza could that be the reason for this error

{
"code": 400,
"details": {},
"url": {
"Scheme": "https",
"Opaque": "",
"User": null,
"Host": "api.paystack.co",
"Path": "/charge",
"RawPath": "",
"ForceQuery": false,
"RawQuery": "",
"Fragment": ""
},
"header": {
"Access-Control-Allow-Origin": [
"*"
],
"Cf-Ray": [
"4130f86afd762993-DUB"
],
"Content-Length": [
"80"
],
"Content-Type": [
"application/json; charset=utf-8"
],
"Date": [
"Sun, 29 Apr 2018 10:08:58 GMT"
],
"Etag": [
"W/"50-1OmteF9EHlts1wNCZyvxIA""
],
"Expect-Ct": [
"max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct""
],
"Server": [
"cloudflare"
],
"Set-Cookie": [
"__cfduid=de2207b3a95cbc631af2eb860d36289131524996538; expires=Mon, 29-Apr-19 10:08:58 GMT; path=/; domain=.paystack.co; HttpOnly",
"sails.sid=s%3A8C9sZpbqB2Csy6aMU41LhyapUfL5tNiU.eDQAaIkJfXqA6PbmC4OVhcgGiC2tjC6ALZ9NhpEpx%2FM; Path=/; HttpOnly; Secure"
],
"Strict-Transport-Security": [
"max-age=15552000; includeSubDomains; preload"
],
"Vary": [
"X-HTTP-Method-Override"
],
"X-Content-Type-Options": [
"nosniff"
],
"X-Powered-By": [
"Sails <sailsjs.org>"
]
}
}

@steveamaza
Copy link
Author

steveamaza commented Apr 29, 2018 via email

@rpip
Copy link
Owner

rpip commented May 9, 2018

Hey guys! Sorry for the late response to this.

UA config was in the code but noticed there was a gap in the logic in how the UA was set. The idea was to allow devs to append custom UAs to the code to further identify where the request is coming from. I have simplified it now so UA is always to set to something like paystack-go/$CURRENT_LIB_VERSION. See https://github.com/rpip/paystack-go/blob/master/paystack.go#L29

@rpip
Copy link
Owner

rpip commented May 9, 2018

Ah the build failed:

{
  "code": 400,
  "details": null,
  "url": {
    "Scheme": "https",
    "Opaque": "",
    "User": null,
    "Host": "api.paystack.co",
    "Path": "/transferrecipient",
    "RawPath": "",
    "ForceQuery": false,
    "RawQuery": "",
    "Fragment": ""
  },
  "header": {
    "Access-Control-Allow-Origin": [
      "*"
    ],
    "Cf-Ray": [
      "4183a89d4fe923c6-IAD"
    ],
    "Content-Length": [
      "63"
    ],
    "Content-Type": [
      "application/json; charset=utf-8"
    ],
    "Date": [
      "Wed, 09 May 2018 10:59:47 GMT"
    ],
    "Etag": [
      "W/\"3f-jtwy0qN2ikmb7AbT8QWXag\""
    ],
    "Expect-Ct": [
      "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\""
    ],
    "Server": [
      "cloudflare"
    ],
    "Set-Cookie": [
      "__cfduid=d378bf28bb40ed403c192fecc043a84e61525863587; expires=Thu, 09-May-19 10:59:47 GMT; path=/; domain=.paystack.co; HttpOnly",
      "sails.sid=s%3AmIH2M2O82TP5W2IvttZLpTXcH68MTljj.fQ%2FsbFnYV3SoVz45zs8lm%2BXY58SHWMkaaMCowZ90QoI; Path=/; HttpOnly; Secure"
    ],
    "Strict-Transport-Security": [
      "max-age=15552000; includeSubDomains; preload"
    ],
    "Vary": [
      "X-HTTP-Method-Override"
    ],
    "X-Content-Type-Options": [
      "nosniff"
    ],
    "X-Powered-By": [
      "Sails <sailsjs.org>"
    ]
  }
}

@rpip
Copy link
Owner

rpip commented May 9, 2018

Updated the UA to use the Mozilla UA @steveamaza suggested, but the build is still failing.

Won't be able to look into this again anytime soon. Happy to give access to anyone interested in helping maintain the lib. Thanks!

@rpip
Copy link
Owner

rpip commented Jul 16, 2018

Hi @steveamaza, actually, it's the transfer test that's failing. The error response from Paystack doesn't indicate why.

TestTransferRecipientList (0.96s) transfer_test.go:95:

{
  "code": 400,
  "details": null,
  "url": {
    "Scheme": "https",
    "Opaque": "",
    "User": null,
    "Host": "api.paystack.co",
    "Path": "/transferrecipient",
    "RawPath": "",
    "ForceQuery": false,
    "RawQuery": "",
    "Fragment": ""
  },
  "header": {
    "Access-Control-Allow-Origin": [
      "*"
    ],
    "Cf-Ray": [
      "4183c08a5d57244a-IAD"
    ],
    "Content-Length": [
      "63"
    ],
    "Content-Type": [
      "application/json; charset=utf-8"
    ],
    "Date": [
      "Wed, 09 May 2018 11:16:07 GMT"
    ],
    "Etag": [
      "W/\"3f-jtwy0qN2ikmb7AbT8QWXag\""
    ],
    "Expect-Ct": [
      "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\""
    ],
    "Server": [
      "cloudflare"
    ],
    "Set-Cookie": [
      "__cfduid=dcbd3d400b01a7db18990bdd903108dd61525864567; expires=Thu, 09-May-19 11:16:07 GMT; path=/; domain=.paystack.co; HttpOnly",
      "sails.sid=s%3AUwZPOMIqNpoQM08VaquhUW16M-xauiGA.wLPqT0Vs2naRzrhfGiWj8G80z%2B5hySsvadfFJcNoJQo; Path=/; HttpOnly; Secure"
    ],
    "Strict-Transport-Security": [
      "max-age=15552000; includeSubDomains; preload"
    ],
    "Vary": [
      "X-HTTP-Method-Override"
    ],
    "X-Content-Type-Options": [
      "nosniff"
    ],
    "X-Powered-By": [
      "Sails <sailsjs.org>"
    ]
  }
}```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants