Mastercard / oauth1-signer-swift

Zero dependency library for generating a Mastercard API compliant OAuth signature.
https://developer.mastercard.com/platform/documentation/security-and-authentication/using-oauth-1a-to-access-mastercard-apis/
MIT License
14 stars 5 forks source link

Unable to run Example project #5

Closed Natelegreat1 closed 3 years ago

Natelegreat1 commented 3 years ago

Setup

Xcode 12.2 (12B45b)

Issue

Hello. I am trying to run the sample (Example) project. I have added my consumerKey, private key certificate & key password. I have tried several services for urlString:

No matter what I try, I get the following error: Alamofire.AFError.responseSerializationFailed(reason: Alamofire.AFError.ResponseSerializationFailureReason.jsonSerializationFailed(error: Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character 0.}))

Any ideas?

piyuhirpara commented 3 years ago

@Natelegreat1 Which Mastercard API you are trying to connect? From the response it looks like you are getting error response which isn't in JSON format.

Natelegreat1 commented 3 years ago

@piyuhirpara I was trying:

piyuhirpara commented 3 years ago

@Natelegreat1

Could you please paste request response logs from the sample app for Open Banking service call.

For Transaction Notifications, correct end point is : https://sandbox.api.mastercard.com/cardbasedconsent/ For more details please refer documentation available here.

Natelegreat1 commented 3 years ago

@piyuhirpara I am using https://api.mastercard.com/openbanking/sandbox/connect/api/ for Open Banking service call - same AFError. Using https://sandbox.api.mastercard.com/cardbasedconsent/ for Transaction Notifications and also getting the same error.

Maybe you can spot something that I changed by mistake?

Screen Shot 2020-11-19 at 12 42 14 PM
TutteRamson commented 3 years ago

Transaction Notification APIs support two calls.

GET https://sandbox.api.mastercard.com/cardbasedconsent/consents/{card_reference}
POST https://sandbox.api.mastercard.com/cardbasedconsent/transactions

The screenshot suggests that you are doing a POST on https://sandbox.api.mastercard.com/cardbasedconsent without the transactions, unless I miss seeing it the right way.

Could you please make the call using the insomnia plugin first to make sure your keys work with the endpoint correctly before trying out the Swift library?

piyuhirpara commented 3 years ago

@Natelegreat1,

In Addition to above answer from Ramson,

You also need to change "payload" according to API endpoint requirement.