Third party subscriptions with KGPugpigAuthorisation

Adding a custom content security provider

The custom security provider requires Pugpig 2.0.

You can limit access to your content by using a custom content security provider. You will need to provide a server component that allows Pugpig to verify access to documents, and it should conform to our server security specification. Check with us; we already have server components for many popular subscription services.

Using our security provider generally means you don't need to worry about writing your own.

Configuring Pugpig to support authorisation

Pugpig needs to know your the details of your authorisation endpoint. Find application:didFinishLaunchingWithOptions: in your app delegate; this is where providers are configured. You should add a KGPugpigAuthorisation provider and specify an endpoint. There are two methods you can choose between to initialise this class with an endpoint.

1.initWithEndpoint:shouldPOSTRequests: This let's you specify a single root endpoint from which all the required endpoints are inferred. For example if you added the endpoint:, the class will add a standard set of subpaths and parameters as follows:

ENDPOINT/sign_in/?PARAMS
Renew ENDPOINT/renew_token/?token=TOKEN
Verify ENDPOINT/verify_subscription/?token=TOKEN
Credentials ENDPOINT/edition_credentials/?token=TOKEN&product_id=PRODUCTID

2. initWithEndpointsForSignIn:renewToken:verifySubscription:editionCredentials:shouldPOSTRequests: allows you to specify all the required endpoints separately as a string array, in the same order as above. If your server does not support the optional “renew” operation, you should specify 'nil' for the renew endpoint. NOTE: Be aware that you need to specify the endpoint with literal placeholders for the parameters. For example, to recreate the same endpoints without a renew_token method you would use:

Setting shouldPOSTRequest to YES will take all the parameters off the end of the string and place them in the HTTP body when POSTing requests.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Powered by Zendesk