How to connect API with oauth? Java

Hi, I have very basic question but I don t have any experience in that and I am starting with ttv api programming.
How to connect to API with oauth in Java. I have seen so many tutorials but most of them are in js, that is quite different thing.
Can someone recommend me good library for twitch and java? Is PircBot still up to date?

EDIT 1:
I have that code:

import javax.net.ssl.HttpsURLConnection;
import java.net.URL;
import java.util.Scanner;

public class Main {
    public static void main(String[] args)
    {
        try
        {
            URL url = new URL("https://id.twitch.tv/oauth2/token");

            HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
            conn.setRequestMethod("POST");
            conn.connect();
            conn.setRequestProperty("client_id=MYID&client_secret=MYSECRET&grant_type=client_credentials","http://localhost:3000" );

            int responseCode = conn.getResponseCode();

            if (responseCode != 200)
            {
                throw new RuntimeException("HttpsResponseCode: "+ responseCode);

            }
            else
            {
                StringBuilder informationString = new StringBuilder();
                Scanner scanner = new Scanner(url.openStream());

                while (scanner.hasNext())
                {
                    informationString.append(scanner.nextLine());
                }
                scanner.close();
                System.out.println(informationString);
            }
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
}

This line is wrong but i don’t understand how to set it properly:

conn.setRequestProperty("client_id=MYID&client_secret=MYSECRET&grant_type=client_credentials","http://localhost:3000" );
Of course i inserted appropriate data in MYID, MYSECRET.

I read instrucions from this site: Getting OAuth Access Tokens | Twitch Developers

I don’t understand that part:

Set the following x-www-form-urlencoded parameters as appropriate for your app.

What x-www-form-urlencoded means? How to implement that in code?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.