use of com.tinyspeck.glitchhq.ServerRequestTask in project glitch-hq-android by tinyspeck.
the class Glitch method login.
public void login(String emailAddress, String password, final GlitchSessionDelegate delegate) {
String sURL = "http://api.glitch.com/oauth2/token";
Vector<BasicNameValuePair> params = new Vector<BasicNameValuePair>(6);
params.add(new BasicNameValuePair("username", emailAddress));
params.add(new BasicNameValuePair("password", password));
params.add(new BasicNameValuePair("grant_type", "password"));
params.add(new BasicNameValuePair("scope", "write"));
params.add(new BasicNameValuePair("client_id", "197-764ef7f4f676f4b53819e52ea7cca4c65badf353"));
params.add(new BasicNameValuePair("client_secret", "584d266525e5d8d7cf17faf9391f0145f12b12c6"));
new ServerRequestTask(sURL, true, params) {
protected void onPostExecute(String result) {
if (result == null) {
delegate.glitchConnectionError();
return;
}
Log.i("glitch", result);
if (result.length() == 0) {
delegate.glitchLoginFail();
return;
}
try {
JSONTokener tokener = new JSONTokener(result);
JSONObject jObject = new JSONObject(tokener);
accessToken = (String) jObject.get("access_token");
delegate.glitchLoginSuccess();
} catch (JSONException e) {
e.printStackTrace();
}
}
}.execute();
}
Aggregations