Question

I am working with the Balanced Payments API and in their example code they make a curl request as such:

curl https://api.balancedpayments.com/v1/customers \
     -u ak-test-PE0kAimMqYDGzebPIHUzYwuLUM86yCxP: \
     -X POST

I am not sure how to pass the -u value in the AFNetworking 2.0 library.

Reference: Balanced Payments API

To authenticate with Balanced, you will need the API key secret provided from the dashboard. You have to use http basic access authentication. Your key has to be set as the username. A password is not required for simplicity.

Was it helpful?

Solution

AFHTTPRequestOperation *operation = // …
NSURLCredential *credential = [NSURLCredential credentialWithUser:@"ak-test-PE0kAimMqYDGzebPIHUzYwuLUM86yCxP:" password:@"unused" persistence:NSURLCredentialPersistenceForSession];
[operation setCredential:credential];

Persistence options are listed here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top