Differences

This shows you the differences between two versions of the page.

Link to this comparison view

api_login [2014/04/09 19:07]
ybarajas [Examples]
api_login [2014/04/09 19:39] (current)
ybarajas [Examples]
Line 1: Line 1:
 +======How to Log In======
 +
 +=====Log In & Obtain Key====
 +
 +==Resource URL==
 +
 +<code>
 +/moservices/rest/api/login
 +</code>
 +
 +==POST Parameters==
 +
 +Required parameters:
 +
 +^ Parameter ^ Description ^
 +|username|N/A|
 +|password|N/A|
 +|User-Agent|This helps us route your API call appropriately. **Default:** //apiuser//|
 +
 +=====Examples=====
 +
 +Logging in with the username “johnsmith@acme.com” and password “changeme”.
 +
 +==cURL:==
 +
 +<code>
 +
 +curl -d "username=john&password=changeme&User-Agent=apiuser" -k -c tmpCookies.txt https://openmobile.ipass.com/moservices/rest/api/login
 +</code>
 +
 +==JAVA:==
 +
 +
 +<code>
 +String loginURI = "/moservices/rest/api/login";
 +HttpPost loginPost = new HttpPost("https://openmobile.ipass.com" + loginURI);
 + 
 +List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
 +nameValuePairs.add(new BasicNameValuePair("username", username));
 +nameValuePairs.add(new BasicNameValuePair("password", password));
 +nameValuePairs.add(new BasicNameValuePair("User-Agent", "apiuser"));
 +loginPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
 + 
 +// Make the Login API call to authenticate 
 +HttpResponse loginResponse = httpClient.execute(loginPost);
 + 
 +// Consume content so the HTTPClient can be re-used
 +loginResponse.getEntity().consumeContent();
 + 
 +// Get Cookies from the Login API call
 +CookieStore cookieStore = ((AbstractHttpClient) httpClient).getCookieStore();
 +List<Cookie> cookies = cookieStore.getCookies();
 + 
 +// Set cookies for future API calls
 +httpClient.getParams().setParameter("Cookie", cookies);
 +</code>
 +
 +
 +Go to: **[[:start|Portal Home]]** > **[[:api_documentation|REST API Overview]]**
 +
  
 

©2015 iPass Inc. All rights reserved. Terms of Use