Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

This content has been archived and is no longer being updated.

Links may not function; however, this content may be relevant to outdated versions of the product.

Authenticating with authorization headers in the Connect SDK for iOS

Updated on September 13, 2021

In the Connect SDK for the iOS platform, you can authenticate to a Pega® Platform application specifying values for authorization headers. Authorization headers are used by the OAuth 2.0 authorization protocol to allow client applications such as mobile apps to use third-party tokens to authenticate with a server. A method is available in the Connect SDK for iOS for this purpose.

Adding an authorization header

Use the setAuthorizationHeader() method for the authenticationService property to set a custom value for an authorization header. An authorization header is a type of custom header that you can use to authenticate with a server. For example, for basic authentication, you can add an authorization header with a value of MY_BASIC_HEADER_VALUE in the following way:

pegaApi.authenticationService.setAuthorizationHeader(header: "MY_BASIC_HEADER_VALUE");

The following code shown demonstrates how to authenticate to a Pega Platform application by using the authenticationService property with an authorization header that has a value of Basic dGVzdC51c2VyOnBhc3N3b3Jk.

let pegaApi = PMPegaApi(serverURL: URL(string: "http://sample.pega.com:8080/prweb/api/v1")!) 
pegaApi.authenticationService.setAuthorizationHeader(header: "Basic dGVzdC51c2VyOnBhc3N3b3Jk") 
// perform an action, for example, get case types

Authenticating without using an authorization header

If you do not need to use authorization headers to authenticate to a Pega Platform application, you can authenticate asynchronously by using the logIn() method and specifying credentials in the following way:

let pegaApi = PMPegaApi(serverURL: URL(string: "http://sample.pega.com:8080/prweb/api/v1")!) 
pegaApi.authenticationService.logIn(user: "test.user", password: "password") { error in 
  guard error == nil else { 
    print("Login error: " + (error?.localizedDescription ?? "")) 
    return 
  } 
  // perform an action, for example, get case types 
​}

With this method of authenticating, the Connect SDK uses the basic authentication internally.

Tags

Pega Platform 7.3.1 - 8.3.1 Pega Web Mashup Mobile Pega Express

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us