Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- headers.put("Content-Type", "application/json; charset=utf-8");
- headers.put("Content-Type", "application/x-www-form-urlencoded");
- try {
- JSONObject js = new JSONObject();
- try {
- js.put("client_id", "HKTPEMS");
- js.put("client_secret", "B83845-9AFDDD-46D7B487D62E13DD86");
- js.put("grant_type", "password");
- js.put("username", firstName);
- js.put("password", password);
- }catch (JSONException e) {
- e.printStackTrace();
- }
- JsonObjectRequest jsonObjReq = new JsonObjectRequest(
- Request.Method.POST, url, js, new Response.Listener<JSONObject>() {
- @Override
- public void onResponse(JSONObject response) {
- Log.e(TAG, "response = " + response.toString());
- iResult.notifySuccess(response);
- ContentValues cv = new ContentValues();
- String accessToken = null;
- String refreshToken = null;
- try {
- //Get the accessToken
- accessToken = (String) response.get("access_token");
- Log.e(TAG, "accessToken = " + accessToken);
- //Get the refreshToken
- refreshToken = (String) response.get("refresh_token");
- Log.e(TAG, "refreshToken = " + refreshToken);
- }catch (Exception e){}
- cv.putNull(LoginValidate.C_ID_TOKENS);
- cv.put(LoginValidate.C_TOKENS_ACCESS_TOKEN, accessToken);
- cv.put(LoginValidate.C_TOKENS_REFRESH_TOKEN, refreshToken);
- appObj.loginValidate.insertIntoTokens(cv);
- cvResult.put("resultcode", "OK");
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
- Log.e(TAG, "Error: " + error.getMessage());
- Log.e(TAG, "Error stackTrace: " + error.getStackTrace().toString());
- iResult.notifyError(error);
- }
- }) {
- @Override
- public Map<String, String> getHeaders() throws AuthFailureError {
- HashMap<String, String> headers = new HashMap<String, String>();
- headers.put("Content-Type", "application/json; charset=utf-8");
- //headers.put("Content-Type", "application/x-www-form-urlencoded");
- return headers;
- }
- };
- RequestQueue queue = appObj.getRequestQueue();
- queue.add(jsonObjReq);
- } catch (Exception e) {
- Log.e("json","e.getLocalizedMessage()"+ e.getLocalizedMessage());
- cvResult.put("resultcode", "ERROR: problem getting the tokens");
- }
- /WebServicesForWebApi: inside WS getAuthenticationTokens()
- E/LoginValidate: url already exists in DB, so returning it
- E/WebServicesForWebApi: checking url for getting tokens. url = https://abc.xyz.co.uk/Token
- E/LoginValidate: password already exists in DB, so returning it
- E/LoginValidate: username already exists in DB, so returning it
- E/WebServicesForWebApi: username = de4bcbc0bac3@XXXX.com
- E/WebServicesForWebApi: password = 90661f6a-11c0-4bb3-b92a-cd9e38dfd229
- E/WebServicesForWebApi: tokenCountInDB = 0
- E/InstallationActivity: ContententsValues for tokens has size = 0
- I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
- I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
- E/Volley: [55345] BasicNetwork.performRequest: Unexpected response code 400 for https://abc.xyz.co.uk/Token
- E/WebServicesForWebApi: Error: null
- E/WebServicesForWebApi: Error stackTrace: [Ljava.lang.StackTraceElement;@33976bc
- E/InstallationActivity: ERROR for getAuthenticationTokens() = com.android.volley.ServerError
Add Comment
Please, Sign In to add comment