Learn R Programming

rappleads (version 0.1.3)

apl_auth: Apple Ads Authorization

Description

Apple Ads Authorization

Usage

apl_auth(
  client_id = Sys.getenv("APL_CLIENT_ID"),
  team_id = Sys.getenv("APL_TEAM_ID"),
  key_id = Sys.getenv("APL_KEY_ID"),
  private_key_path = Sys.getenv("APL_PRIVATE_KEY_PATH"),
  account_name = Sys.getenv("APL_ACCOUNT_NAME"),
  cache_path = rappdirs::site_data_dir("rappleads")
)

Value

character with access_token

Arguments

client_id

You receive your clientId when you upload a public key.

team_id

The client secret is a JWT that you create and sign with your private key.

key_id

The value is your keyId that returns when you upload a public key.

private_key_path

Path to the .pem file containing your private key.

account_name

Your apple ads account name

cache_path

Path to the directory where cached authentication data will be stored.

Details

This implementation process guides you through the following steps:

  1. Invite users with API permissions.

  2. Generate a private-public key pair.

  3. Extract a public key from your persisted private key.

  4. Upload a public key.

  5. Set system environments variables.

  6. Request an access token.

Generate a Private Key

API users need to create a private key. If you’re using MacOS or a UNIX-like operating system, OpenSSL works natively. If you’re on a Windows platform, you need to download OpenSSL. openssl ecparam -genkey -name prime256v1 -noout -out private-key.pem

Extract a Public Key

openssl ec -in private-key.pem -pubout -out public-key.pem Open the public-key.pem file in a text editor and copy the public key, including the begin and end lines.

Upload a Public Key

Follow these steps to upload your public key:

  1. From the Ads UI, choose Account Settings > API. Paste the key created in the above section into the Public Key field.

  2. Click Save. A group of credentials displays as a code block above the public key field. Use your clientId, teamId, and keyId to create a client secret.

Set system environments variables

Run usethis::edit_r_environ() and set variables:

  • APL_CLIENT_ID

  • APL_TEAM_ID

  • APL_KEY_ID

  • APL_PRIVATE_KEY_PATH

  • APL_ACCOUNT_NAME

Request an access token.

Once the environment variables listed above are set, no further action is required from you — any function from the package will automatically request and refresh the access token when executed.

For more information see API Oauth documentation.