Skip to Content
Technical Articles

Migration of Android application from Neo environment to Cloud Foundry environment with oAuth Configuration

If the version of your SAP BTP SDK for Android is in between 3.0 and 3.1 releases, this blog post will help you migrate Android Application configured with oAuth from Neo environment to Cloud Foundry environment.

Following is the list of tools I used:

  • Android Studio 4.0.1
  • Android SDK 28
  • SAP BTP SDK Android 3.1.3
  • Java Development Kit 14.0.2

For getting more insights, read:

Follow the steps given below to migrate your android application from Neo environment to Cloud Foundry environment with oAuth configuration.

 

Now let’s create an application in Neo environment with oAuth configuration:

  1. Open mobile services cockpit (neo environment) and under Mobile Applications select Native/Hybrid.
  2. Click on the new button, a dialog box will appear. Enter the following details and click on Save.
    Config Templates Native
    ID com.sap.migrationOAuth
    Name MigrationOAuth

  3. Once the app is created, under the Assigned Features section, click on Connectivity.
  4. Click on create button. Enter the following details and click next.
    Type Mobile Destination
    Destination Name es5DemoSystem

    Enter the URL ‘https://sapes5.sapdevcenter.com/sap/opu/odata/sap/EPM_REF_APPS_SHOP_SRV’ and click next until you reach the SSO Mechanism page. Choose ‘Basic Authentication’ and click next. Enter your username and Password and click next and then click finish.

  5. Click on the MigrationOAuth in the breadcrumb menu and under the assigned features, click on Security.
  6. Select oAuth from the dropdown in the security configuration field and click Save.
  7. Open your Android Studio, click on Start a new SAP Cloud Platform Android Project.
  8. Enter the following details and click on Next.
    Account Name Neo Mobile Services
    Admin API URL Refer the note below.
    Admin UI URL Refer the note below.
    Authentication Type SAML
    Username Your BTP account username
    Password Your BTP account password

    NOTE: For the Admin API URL and Admin UI URL, click on the Important Links tab in the Mobile Services Cockpit, and copy the Admin API and Admin UI.

  9. Select com.sap.migrationOAuth from the drop down and click next.
  10. Select es5DemoSystem and click next.
  11. Give the Project Name as MigrationOAuth, Project Namespace as com.sap.migrationoauth and click next and then click finish.
  12. Wait for the application to load completely. Open app -> java -> com.sap.migrationoauth -> app -> WelcomeActivity.java. You can see your Neo tenant’s URL. Now, run the app on your device.

You can see that the application is running on Neo environment.

 

Now export the application configuration from your Neo mobile services cockpit. A zip file will be downloaded.

Open your Cloud foundry mobile services cockpit and under mobile applications select Native/Hybrid.

Click on Import and browse the location of your file and click Save.

Once import is complete, you will get a toast message “Application imported successfully”.

 

Now, click on MigrationOAuth and click on the API tab and download the configuration for your android device.

Open the defaultConfig.json file and replace the following in WelcomeActivity.java:

Copy (from defaultConfig.json) Replace with (in Android Studio)
authorizationEndpoint’s value authorizationEndpoint’s value – line 104
tokenEndpoint’s value tokenEndpoint’s value – line 105
clientID’s value clientID’s value – line 106
redirectURL’s value redirectURL’s value – line 106
grantType’s value grantType’s value –  line 106
Host’s value host’s value – line 111

Uninstall the application you installed earlier and run the application again.

You will see that your app is pointing to Cloud Foundry environment now which means you successfully migrated your android application from Neo environment to Cloud Foundry environment with oAuth configuration.

If the version of your SAP BTP SDK for Android is 3.2.0 or above, follow the steps given below:

  1. In your android project, go inside app -> res -> raw folder. Here, you will see sap_mobile_services.json file.
  2. Replace the following values in sap_mobile_services.json from defaultConfig.json file:
    Copy (from defaultConfig.json) Replace with (in Android Studio)
    authorizationEndpoint’s value authorizationEndpoint’s value – line 11
    tokenEndpoint’s value tokenEndpoint’s value – line 10
    clientID’s value clientID’s value – line 8
    redirectURL’s value redirectURL’s value – line 8
    grantType’s value grantType’s value – line 8
    endUserUI’s value endUserUI’s value – line 12
    ServiceURL’s value ServiceURL’s value – line 16

NOTE: For version 2.3 or below, the file name is configurationprovider.json and not sap_moblie_services.json where you need to do the above mentioned changes.

Now, uninstall the application you installed earlier and run the application.

You will see that your app is pointing to Cloud Foundry environment now which means you successfully migrated your android application from Neo environment to Cloud Foundry environment with SAML configuration.

Be the first to leave a comment
You must be Logged on to comment or reply to a post.