private static void getAccessAndRefreshTokensFromAuthorizationCode(
			TokenType t) {

		flagAccessToken = false;

		// builds POST parameters
		List<NameValuePair> parameters = new ArrayList<NameValuePair>();
		parameters.add(new BasicNameValuePair("client_id", clientId));
		parameters.add(new BasicNameValuePair("client_secret", apiKey));

		if (t == TokenType.ACCESS) {
			parameters.add(new BasicNameValuePair("grant_type",
					"authorization_code"));
			parameters.add(new BasicNameValuePair("code", authorizationCode));

		}
		if (t == TokenType.REFRESH) {

			if (refreshToken == null) {
				flagAccessToken = true;
				return;
			}
			parameters
					.add(new BasicNameValuePair("grant_type", "refresh_token"));
			parameters
					.add(new BasicNameValuePair("refresh_token", refreshToken));

		}

		// executes POST
		String output = sendHttpPost(
				"https://www.freesound.org/apiv2/oauth2/access_token/",
				parameters);

		// extracts access token and refresh token
		try {
			JsonObject response = JsonObject.readFrom(output);
			accessToken = response.get("access_token").asString();
			refreshToken = response.get("refresh_token").asString();

			// saves refresh token
			OutputLog o = new OutputLog("refresh_token.json");
			JsonObject j = new JsonObject();
			j.add("refresh_token", refreshToken);
			o.writeJsonObjectToFile(j);

		} catch (ParseException e) {
			e.printStackTrace();
			flagAccessToken = true;
			return;
		} catch (UnsupportedOperationException e) {
			e.printStackTrace();
			flagAccessToken = true;
			return;
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			flagAccessToken = true;
			return;
		}

	}