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.
- Defining and configuring an application in SCPms
- Putting together our registration request in Postman
- Syncing the URLs between SCPms and Postman
1. Defining and configuring an application in SCPms
- Defining the app
- Open SCP.
- Go to Services.
- Choose Mobiles Services for Development and Operations.
- Click “Go to Service”.
- Choose “Mobile Applications” and “Native/Hybrid”
- Click New and fill the fields like this (you can set both Native or Hybrid):
- Click Save.
- Now click on the Connectivity Feature.
- Click on the Add sign.
- Choose a Destination and click OK. In this example I use the ESPM sample service.
- Adding OAuth as an Authentication Provider:
- Now go back and choose the Security Feature.
- Set the Security Configuration to OAuth.
- Create a new OAuth Client by clicking the Add sign.
- It’s not necessary to do anything here now so just click OK.
- 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
- Open Postman.
- Choose the POST verb.
- Set the URL to:
- In the Authorization tab, set the Type to OAuth 2.0
- In the Headers tab, add Content-Type as key with the value: application/xml
- 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>email@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 try to help you.