Many web services use some kind of authentication method to secure access to the web service. There are a lot of authentication types available, one of which is Basic Authentication. In this How-To we will guide you through the process of setting up Basic Authentication for your Web Service.
Prerequisites
- A web service that requires Basic Authentication;
How To
- Go to http://design.appmachine.com and login;
- Select an existing app or create a new app;
- Click the "Add block" button;
- Select the "Pro" tab;
- Select the "Web Service" block and click "Add Block";
- Click "Custom Web Service";
- Enter the URL of your Web Service;
- Now you need to specify the Basic Authentication. AppMachine uses (so called) Authorization Providers to specify any type of authentication that should be used during a Web Service call. So to setup Basic Authentication we need to create a Basic Authentication Authorization Provider. To do so, click the "+" button next to the Authorization provider field.
- A wizard will open. This wizard will allow you to create a new Authorization Provider. First you will need to switch the Type to Basic;
- You will see that the number of fields you will have to fill out will be reduced to just Three;
- First we will give the Authorization Provider a recognizable name;
- Next, enter the Username and Password;
- By enabling the option "Use my credentials in the app" the Web Service will always use the username and password you provided. Otherwise the user will be prompted to enter their username and password.
- Click "Finish";
- Select the Authorization Provider you've just created;
- Click "Go";
- We will perform a test call using the specified credentials, and when successful you can finish the Web Service integration;
Comments
5 comments
Thanks, is the user capable of storing the username and password?
Yes, if you disable the option "Use my credentials in the app" the app will prompt the user to enter their username and password. Those will be stored locally and will be used to access your REST Service. The moment your service starts returning HTTP Error 401 - Unauthorized we will discard the credentials and prompt the user to enter their credentials again.
Please note, this feature is not yet available, but will be available in the next update, probably this week.
this method does not work with username for parse (which is email) and password. I get "an error occurred while executing the web service"
Khoi, I've gotten past that issue... You have to Decode the E-mail on the Server side, because the URL query is being Encoded when sending.
Dear Matthijs,
I've tried your solution. But it doesn't seem to work. The credentials do not get discarded and I 'm not prompted to enter my credentials again.
Was this implemented?
Please sign in to leave a comment.