0

I'm attempting to log into the Freelancer.com web api over http, but cannot get past the authentication. It's for a desktop app in java that I can run from prompt, so nothing fancy, but I cant seem to get past step 1 of the process, receiving the authorisation response.

package project.monitor;

import java.io.IOException;
import org.jsoup.Connection;
import org.jsoup.Jsoup;

public class api {

    public static void main(String[] args) throws IOException {

        String authEndPoint = "https://accounts.freelancer.com/oauth/authorise";
        String apiEndPoint = "https://freelancer.com/api";

        String str = "https://accounts.freelancer.com/oauth/authorise?" + "response_type=code"
                + "&client_id=<647f4785-fe45-4182-b97a-f401e0b0d641>" + "&redirect_uri=<https://www.google.com/>"
                + "&scope=basic" + "&prompt=select_account%20consent&advanced_scopes=1%203";

        String json = Jsoup.connect(str).ignoreContentType(true).execute().body();
        System.out.println(json);

    }

}

Documentation: https://developers.freelancer.com/docs/authentication/generating-access-tokens

The first step is to redirect your user to the Freelancer.com Identity 
authorise url. This redirect prompts the user to give your application 
permission to access their protected resources. When a user grants 
permission, they will be redirected to an endpoint on your server with an 
authorization code to be used in the following steps

How is this done? How do i redirect the authorisation code back to my program in eclipse?

Soulwake
  • 45
  • 7

1 Answers1

0

Got there in the end. For the benefit of others;

In a typical standalone application running from a desktop, the correct grant type would be the Client Credentials grant type.

By using the client credentials flow, your application generates an OAuth access token for the owner of that application. So if your application only needs to authenticate as the owner of that application, then you can use the client credentials grant type.

Soulwake
  • 45
  • 7