Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
grabz
Advisor
Advisor
1,371
Goal:

This blog is demonstrating step-by-step how to register with Postman to SAP Cloud Platform Mobile Services for Development and Operations via OAuth. Despite its primary goal is not to give a better understanding of the OAuth flow with SCPms, hopefully it will so.

Content:

  1. Defining and configuring an application in SCPms

  2. Putting together our registration request in Postman

  3. Syncing the URLs between SCPms and Postman


1. Defining and configuring an application in SCPms

The process:

  1. Defining the app

    1. Open SCP.

    2. Go to Services.

    3. Choose Mobiles Services for Development and Operations.

    4. Click "Go to Service".

    5. Choose "Mobile Applications" and "Native/Hybrid"

    6. Click New and fill the fields like this (you can set both Native or Hybrid):

    7. Click Save.

    8. Now click on the Connectivity Feature.

    9. Click on the Add sign.

    10. Choose a Destination and click OK. In this example I use the ESPM sample service.



  2. Adding OAuth as an Authentication Provider:

    1. Now go back and choose the Security Feature.

    2. Set the Security Configuration to OAuth.

    3. Create a new OAuth Client by clicking the Add sign.

    4. It's not necessary to do anything here now so just click OK.

    5. Now click Save and the URLs will be populated. You can check it if you click on your OAuth Client.




2. Putting together our registration request in Postman

  1. Open Postman.

  2. Choose the POST verb.

  3. Set the URL to:


  4. In the Authorization tab, set the Type to OAuth 2.0

  5. In the Headers tab, add Content-Type as key with the value: application/xml

  6. In the Body tab, add the below text as raw.
    Note: none of the properties are mandatory. The usage of them however might eases some administrator tasks.


<?xml version="1.0" encoding="utf-8"?> 
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
<content type="application/xml">
<m:properties>
<d:DeviceType>iPhone</d:DeviceType>
<d:DeviceModel>Apple</d:DeviceModel>
<d:DeviceSubType>iPhone 7</d:DeviceSubType>
<d:DevicePhoneNumber>+1/23456789</d:DevicePhoneNumber>
<d:DeviceIMSI>test1234</d:DeviceIMSI>
<d:UserLocale>hu</d:UserLocale>
<d:TimeZone>CET</d:TimeZone>
<d:LastKnownLocation>Budapest</d:LastKnownLocation>
<d:Email>example@example.com</d:Email>
</m:properties>
</content>
</entry>

3. Syncing the URLs between SCPms and Postman

1. Go back to the Authorization tab and click on Get New Access Token
2. Copy the Callback URL.
3. Go to SCP.
4. Choose Security and OAuth.
5. Go to the Clients tab.
6. Choose your OAuth client and Edit it.
7. Insert the copied Callback URL (7th point) to the Redirect URI and click Save.
8. Go back to SCPms > our app > Security feature and click on the OAuth Client that we                 created
9. Copy the Authorization Endpoint (use the shortcut).
10. Open Postman and add it as Auth URL.
11. In SCPms now copy the Token Endpoint.
12. In Postman add it into the Access Token URL field.
13. In SCPms copy the Client ID.
14. In Postman add it into the Client ID field.
15. Set the Grant Type to Authorization Code and click Request Token.
16. A pop up window will appear and disappear as you're authenticated.
17. Now click on your token and choose Header from the "Add token to" dropdown list.
18. If you click to the Headers tab (the upper one) then you'll see that your Authorization                    header is set to Bearer <encodedTokenValue>
19. Now you can go back and Send our request.
20. You received your 201 Created Response and now in SCPms under User                                    Registrations you can see that you successfully registered your client with OAuth.


If you had any issues with the blog then leave a comment and I'll help you.
3 Comments