Hello,
I am trying to make a call from an android app to auth0 /oauth/token to get my token.
I am sending all the parameters needed but I am still getting back a 401 and I am confused why.
That’s how I send the parameters:
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestMethod(“POST”);
urlConnection.setRequestProperty(“Content-Type”, “application/x-www-form-urlencoded”);
//post parameters to url
urlConnection.setDoInput(true);
urlConnection.setDoOutput(true);
urlConnection.setRequestProperty(“Charset”, “UTF-8”);
//to add parameters in the uri
Uri.Builder builder = new Uri.Builder()
.authority(url.toString())
.appendQueryParameter(“grant_type”, grant_type)
.appendQueryParameter(“client_id”, client_id)
.appendQueryParameter(“audience”, audience)
.appendQueryParameter(“username”, email)
.appendQueryParameter(“password”, password)
.appendQueryParameter(“scope”, scope)
.appendQueryParameter(“client_secret”, client_secret);
builder.build().getEncodedQuery();
urlConnection.setReadTimeout(10000 /* milliseconds /);
urlConnection.setConnectTimeout(15000 / milliseconds */);
urlConnection.connect();
int responseCode = urlConnection.getResponseCode();
and my responseCode=401.
I am not sure if it’s a java code problem or a auth0 call problem.