Using App Safer Open API

Prev Next

Available in Classic and VPC

You can use the App Management feature of App Safer with 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 with the App Safer Open API. To set build automation:

Note

Build automation is only available for Android apps registered using the simple application method.

  1. From the NAVER Cloud Platform console, navigate to i_menu > Services > Security > App Safer.

  2. Register your app in the App Management menu.

    • For more information on how to register an app, see Register app.
  3. Click on the app you want from the list of apps displayed in the App Management menu.

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

  5. Click [Download script] at the bottom of the registration settings view popup.

    • The script file is downloaded to your local PC.
  6. See API authentication key and check your authentication key.

    • Copy the Access Key and Secret Key values, as they are needed when using APIs.
    • If you are using a sub account and the My Account > Account and security management > Security management > Access management > API authentication key management menu is not displayed, it means the main account has not allowed access to API Gateway. Request API Gateway access from the main account.
    • As for sub accounts, API requests with no permissions are denied. Before running the script, make sure the following permissions are added:
      • createPackage
      • getPackageDetail
      • downloadPackage
  7. Check if the script runs properly in the API tool.

     usage: appsafer.py [-h] --access-key ACCESS_KEY --secret-key SECRET_KEY
                         package out
    
    • When the script runs properly, the following interface appears:
      appsafer-api_sample.png
  8. Copy the downloaded script file to the same path as the build.gradle file in the project.

  9. 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
            }
        }
    }
    
  10. Run the build, and check the results.

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