-
Notifications
You must be signed in to change notification settings - Fork 3
Home
The username and password for the Automatic API are different than the username and password that you use to login to the iOS app. This wiki page will walk you through how to find the API username and password.
To find your username and password, we'll proxy all HTTP traffic from your phone through your computer, so that you can watch as your phone connects to the API. Then you can peek at the authentication it uses, and re-use that username and password in this PHP API.
Finding your API username and password depends on you already having your Automatic iOS app installed and working. If you haven't already, head over to iTunes store to download and install the app: https://itunes.apple.com/us/app/automatic/id596594365?mt=8
Head over to http://www.charlesproxy.com/ and download and install Charles, the web proxy app. After installing it, open it up and you should see "Recording" in its lower right hand corner:
In order for Charles to securely proxy the encrypted information between Automatic and your iOS device, it needs to decrypt and then re-encrypt all of the traffic. The problem is that re-encrypting with Automatic's valid SSL certificate isn't possible, so Charles re-encrypts with its own SSL certificate instead.
In order for your iOS device to trust the Charles SSL certificate, it needs to be explicitly installed onto the device.
Go to http://www.charlesproxy.com/documentation/using-charles/ssl-certificates/ and download the Charles certificate.
At the time of writing, the current Mac OS version of the utility can be found from http://support.apple.com/kb/DL1465. Alternatively, you can also search for the most recent Mac or Windows utility at Apple's site: http://support.apple.com/kb/index?page=search&src=support_site.home.search&locale=en_US&q=iphone%20configuration%20utility.
Open the iPhone Configuration Utility and select "Configuration Profiles" from the Library in the sidebar.
Next create a new Profile:
and fill out all of the information in the General tab.
Next, choose the "Credentials" option of the new profile
Press the "Configure" button that shows, and then choose the .crt file that you downloaded from the Charles website. This will add the certificate the profile. Next, we'll install the profile to the device!
In the device list on the sidebar of the iPhone Configuration Utility, select your device:
and then choose the Configuration Profile tab
This will push the profile onto your phone, and will open it up for you to confirm that you want to install it. Continue the process on your phone and press the Install button:
When Charles is recording, it's running a proxy server on your network. The next step will be to tell your iPhone about this proxy server - but before we can do that we need to know where your computer is. On the Mac, you can use Network Utility to find your IP Address. On Windows... I've no idea.
When Network Utility is open, if you're on Wi-Fi, then select Wi-Fi from the drop down and note the IP shown:
Open the Settings on your iPhone, and enter the Wifi settings. Next, tap on the (i) next to the wifi name that you're connected to:
Last, scroll down and choose manual proxy, and enter the IP address that you found in the previous step. For port, type 8888.
Open up Safari on your iPhone, and you should start seeing activity in Charles. If you don't - then retry the above steps. If you do, then go to the next step!
When you open the Automatic app, you'll see entries for "secure.milesense.com" in Charles - this is the Automatic API! All of these requests are sent over SSL, so initially we won't be able to see much about them besides that they're happening.
Next, we need to decrypt these SSL calls so we can see the username and password that's being used. Right click the secure.milesense.com directory, and enable SSL Proxy:
Next, switch Charles into Sequence view so that you can easily see HTTP requests chronologically:
Now close and re-open the app, and select the last milesense.com request in the list in Charles
Select the last milesense.com HTTP request in the sequence view:
Then choose the Request tab:
And lastly, choose the Authentication tab at the bottom of the screen:
Now you'll be able to see the UserID and Password to use in the API!