Using App Safer Open API
    • PDF

    Using App Safer Open API

    • PDF

    Article Summary

    Available in Classic and VPC

    This section describes how to use the App Management feature of App Safer through Open API.

    Note

    AppSafer Open API is available without a separate subscription, and the API details can be accessed through Swagger UI.

    Build Automation

    You can set up App Safer to be automatically applied when building apps through the App Safer Open API. To set build automation, follow these steps:

    Note

    Build automation can only be used with Android apps registered in the easy application method.

    1. Click the environment you are using in the Region menu and the Platform menu on the NAVER Cloud Platform console.

    2. Click the Services > Security > App Safer one by one in order.

    3. Register your app in the App Management menu.

      • For detailed description on how to register an app, refer to Register apps.
    4. Once in the App Management menu, click on the app you want from the displayed list of apps.

    5. In the detailed information area that expands upon selection, click the [View details] button in the Registration settings.
      appsafer-api_detail_ko

    6. At the bottom of the registration settings view the popup window, click the [Download script] button.

      • The script file will be downloaded to your local PC.
    7. Check your API authentication keys by going to My Page > Account Management > Authentication Key Management in the NAVER Cloud Platform portal.

      • Copy the Access Key and Secret Key values, as they are needed for API use.
      • If you are using a sub account and the Authentication Key Management menu does not appear in the portal, it means the main account has not allowed access to the API Gateway. Request API Gateway access permission from the main account.
      • API requests without permissions are denied for sub accounts. Before running the script, make sure the following permissions are added.
        • createPackage
        • getPackageDetail
        • downloadPackage
    8. Check if the script runs properly in the API tool.

       usage: appsafer.py [-h] --access-key ACCESS_KEY --secret-key SECRET_KEY
                           [--rule RULE]
                           package out
      
      • When the script runs properly, the following screen appears.
        appsafer-api_sample.png

      You can add the AppSafer RULE in the following order:

      1. Create a separate file containing the RULE content. For example, create my_rule_file file.
      2. Add the path to the RULE file to the script's '--rule' parameter. For example, --rule ~ /my_rule_file
    9. Copy the downloaded script file to the same path as the build.gradle file in the project.

    10. Add the following code to the build.gradle file, and enter the Access Key and Secret Key.

      • APK
      // * prepare for apk * /
      applicationVariants.all { variant ->
          def accessKey = "{ACCESS_KEY}";
          def secretKey = "{SECRET_KEY}";
      
          def apkPath = variant.outputs.stream().map({i -> i.getOutputFile()}).findFirst().get().getAbsolutePath();
          variant.getPackageApplicationProvider().get().doLast() {
              exec {
                  commandLine 'python', 'appsafer.py', apkPath, apkPath, "--access-key", accessKey, "--secret-key", secretKey
              }
          }
      }
      
      • App Bundle
      // * prepare for bundle * /
      applicationVariants.all { variant ->
          def accessKey = "{ACCESS_KEY}";
          def secretKey = "{SECRET_KEY}";
      
          def bundleTaskName = "package${variant.name.capitalize()}Bundle"
          def bundleTask = tasks.findByPath(bundleTaskName)
      
          def bundlePath = bundleTask.bundleFile.get().getAsFile().getAbsolutePath()
          bundleTask.doLast {
              exec {
                      commandLine 'python', 'appsafer.py', bundlePath, bundlePath, "--access-key", accessKey, "--secret-key", secretKey
              }
          }
      }
      
    11. After running the build, check the results.

      • If successful, an app with App Safer automatically applied will be created in the outputs folder, and the app will also be registered in the NAVER Cloud Platform console.
        appsafer-api_result

    Was this article helpful?

    What's Next
    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.