Problem logging in using Android App


I’m having an issue when logging in using the android app, I’ve used the same links used in Postman API for POST request but when I log in using the Android app it gives an internal server error, this code that I have is also used by my colleague and he can login, but my app can’t, I have no idea why, can anyone help?


what is the URL you calling in your code?



This is the end point you need to call for getting access token.

curl --request POST \
  --url \
  --header 'content-type: application/x-www-form-urlencoded' \
  --data 'grant_type=password&client_id=<get from web dashboard>&client_secret=<get from web dashboard>&username=<email>&password=<password>


I see, I have to try this out, thank you so much!


I have a similar problem using JAVA Android.
The details are here


Okay so the new link works, but I’m getting a 401 Unauthorized, I think it has something to do with my code, Can anyone help me?


change email to username
TokenPairs.add(new KeyValuePair<string, string>("username", HttpUtility.UrlEncode(mail)));


I did change it, but it still gives me an Unauthorized error unfortunately


Hi, Just an update, it finally worked! here’s the revised code if anyone stumbles upon the same problem as mine, thank you so much!!


What was the issue can you point it out


The issue that I was having is that my code is sending the incorrect url encoded content from the post request in the C# code, what I did is I rearranged the List first before encoding it to an x-www-form-urlencoded content, apparently i’m being redundant with the declaration of the ContentType in the previous image.


Can you share your code here

public async void LoginProcess(string mail, string pass, ProgressDialog Foo, AlertDialog.Builder Bar, Context context)
            var HTTP_Client = new HttpClient();
            HTTP_Client.BaseAddress = new Uri("");
            var HTTP_Request = new HttpRequestMessage(HttpMethod.Post, "/auth/realms/cayenne/protocol/openid-connect/token");

            var RequestData = new List<KeyValuePair<string, string>>();

            RequestData.Add(new KeyValuePair<string, string>("grant_type", "password"));
            RequestData.Add(new KeyValuePair<string, string>("client_id", "[my_Client_ID]"));
            RequestData.Add(new KeyValuePair<string, string>("client_secret", "[my_Client_Secret]"));
            RequestData.Add(new KeyValuePair<string, string>("username", mail));
            RequestData.Add(new KeyValuePair<string, string>("password", pass));

            HTTP_Request.Content = new FormUrlEncodedContent(RequestData);

            var FormResponse = await HTTP_Client.SendAsync(HTTP_Request);

            if (FormResponse.IsSuccessStatusCode)
                var Authentication_Response = await FormResponse.Content.ReadAsStringAsync();

                var Response_Tokens = JsonConvert.DeserializeObject<RootObject>(Authentication_Response);

                Toast.MakeText(context, "Login Successful!", ToastLength.Short).Show();
                AlertDialog CredentialError = Bar.Create();
                CredentialError.SetTitle("Trouble processing request");
                CredentialError.SetMessage("Error Code: " + FormResponse.StatusCode.ToString());
                CredentialError.SetButton("OK", (c, ev) => { });
        catch (HttpRequestException RequestFailed)
            AlertDialog CredentialError = Bar.Create();
            CredentialError.SetTitle("Trouble logging in: request failed");
            CredentialError.SetButton("OK", (c, ev) => { });
        catch(Exception LoginFailed)
            AlertDialog CredentialError = Bar.Create();
            CredentialError.SetTitle("Trouble logging in: login failed");
            CredentialError.SetMessage(LoginFailed.Message + "\n");
            CredentialError.SetButton("OK", (c, ev) => { });