title: Return value from OkHttpClient async request
body: <p>In my first android project i made an onClick event to call a function: </p>
  
  <pre><code>public void doSomething(View v) {
          String result = authenticate();
          [...]
  }
  </code></pre>
  
  <p>This function calls the method:</p>
  
  <pre><code>private String authenticate() {
          OkHttpClient client = new OkHttpClient();
  
          [...]
  
          client.newCall(request).enqueue(new Callback() {
              @Override
              public void onFailure(Call call, IOException e) {
                  [...]
              }
  
              @Override
              public void onResponse(Call call, Response response) throws IOException {
                  if (response.isSuccessful()) {
                      String responseString = response.body().string();
  
                      try {
                          JSONObject responseObject = new JSONObject(responseString);
                          String responseObjectAccessToken = responseObject.getString("accesstoken");
                      } catch (JSONException e) {
                          e.printStackTrace();
                      }
                  }
              }
          });
      }
  </code></pre>
  
  <p>now i would like to return the <strong>responseObjectAccessToken</strong> to my <strong>doSomething</strong> function. A detailed explanation would be great since I am new to Java and Android Studio.</p>