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 custom headers in the Connect SDK for Android

Updated on September 13, 2021

With the Connect SDK for the Android platform, you can authenticate to a Pega® Platform application by using custom headers. Custom headers are a feature of the OAuth 2.0 authorization protocol that allow client applications such as mobile apps to use third-party tokens to authenticate with a server. Several Java methods are available in the Connect SDK for Android for this purpose.

Adding a custom header

Use the addHeader() method in the configuration class to add a custom header consisting of a header name and a header value:

pega.configuration().addHeader("<header_name>", "<header_value>");

You can also use the addAuthorizationHeader() method for the configuration class to add an authorization header. An authorization header is a type of a custom header that you can use to authenticate with a server. For example, to add an authorization header with a value of MY_ACCESS_TOKEN, you can use the following code:

pega.configuration().addAuthorizationHeader("Bearer MY_ACCESS_TOKEN");

Authenticating without custom headers

When you authenticate to a Pega Platform application by using custom headers with one of the methods listed above, you do not need to use the authenticator() method. If you do not use custom headers with your application, you can authenticate asynchronously by using the login() method:

  pega.authenticator().login("username", "password");
​} catch(ApiException e) {
  // login failed
​//login succeeded

You can also authenticate synchronously with the login() method:

pega.authenticator().login("username", "password", new Authentication.LoginCallback() {
  void onSuccess() {
    // login succeeded
  void onFailure(ApiException e) {
    // login failed

Removing custom headers

If you use custom headers with the Connect SDK for Android, you can remove them when they are no longer needed in your application.

  • To remove an authorization header, call the following method:
  • To remove a single custom header that contains a header name, call the following method:
  • To remove all custom headers, call the following method:


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. is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us