GoTo Developer

Java SDK

The SDKs do NOT support:

  • GoToAssist Service Desk
  • GoToAssist Remote Support
  • GoToAssist Corporate
  • Admin
  • SCIM

The available SDKs are licensed under the Developer API Terms of Use.

Installation

Install from the Maven repository

All SDKs are available as packages on the Maven repository. To use them add a dependency on com.logmein.gotomeeting-api, com.logmein.gotowebinar-api, com.logmein.goto-core-lib or com.logmein.gotowebinar-api in your project's pom.xml.

GoToWebinar

<dependency>
  <groupId>com.logmein</groupId>
  <artifactId>gotowebinar-api</artifactId>
  <version>2.9.0</version>
</dependency>

GoToMeeting

<dependency>
  <groupId>com.logmein</groupId>
  <artifactId>gotomeeting-api</artifactId>
  <version>1.1.0</version>
</dependency>

GoToTraining

<dependency>
  <groupId>com.logmein</groupId>
  <artifactId>gototraining-api</artifactId>
  <version>1.00.0</version>
</dependency>

GoTo Core

<dependency>
  <groupId>com.logmein</groupId>
  <artifactId>goto-core-lib</artifactId>
  <version>3.0.0</version>
</dependency>

Getting Started

The following tips assume that you already have

  • a GoTo product account
  • a GoTo developer account
  • a client ID for the respective GoTo product. You obtain this ID after creating a client in your developer account.

If you do not, please refer to steps 1-3 of our Getting started guide.

To integrate the GoTo product into your application you need to install the homonymous SDK as well as the core library for authentication. For example, to develop for GoToWebinar, you need to install gotowebinar-api and goto-core-lib.

Before you make any calls you need to authenticate and obtain an access token.

OAuth Flow

The first step is to generate the authorization URL where the user's browser will be directed. For this you'll need your app's client ID and optionally the URL where the user will be redirected after the authorization to use your application:

import com.logmein.gotocorelib.api;
import com.logmein.gotocorelib.api.model.TokenResponse;
...
String clientId = "nMf9SaIASQ7Jy94Ehyq8GcyopR4MQSbp";
String clientSecret = "loHznAxTuXGfFaMQ";
OAuth2Api oauth2Api = new OAuth2Api(clientId, clientSecret);
String authUrl = oauth2Api.getOAuth2AuthorizationUrl(); // => "https://authentication.logmeininc.com/oauth/authorize?client_id=nMf9SaIASQ7Jy94Ehyq8GcyopR4MQSbp&response_type=code"

Then you need to direct your user's browser to this authorization URL. The user will now login with their GoTo product account credentials and click "Approve" to allow your application access to their product data. After approval, the user will be redirected and you need to capture this redirection URL in order to extract from it the OAuth flow response key. You will use the latter to obtain your access token, for example:

/* using HtmlUnit as a GUI-less browser simulation */
URL url = htmlPage.getUrl(); // as string: "http://example.com/redirect-url?code=a2647d1379894cc2001eb31689cacccc"
String responseKey = oauth2Api.getResponseKey(url); // => "a2647d1379894cc2001eb31689cacccc"
TokenResponse response = oauth2Api.getAccessTokenResponse(responseKey);
String accessToken = response.getAccessToken(); // => "RlUe11faKeyCWxZToK3nk0uTKAL"

Direct Login (Deprecated)

This authentication API is now deprecated. All new clients will not be able to use this API. If you have a client for which the direct login works, that will continue to work for now.

import com.logmein.gotocorelib.api;
import com.logmein.gotocorelib.api.model.TokenResponse;
...
String userName = "test@test.com";
String userPassword = "abcxyz";
String clientId = "nMf9SaIASQ7Jy94Ehyq8GcyopR4MQSbp";
String clientSecret = "loHznAxTuXGfFaMQ";
String redirectUrl = "http://example.com/redirect-url";
OAuth2Api authApi = new OAuth2Api(clientId, clientSecret);
TokenResponse response = authApi.getAccessTokenResponse(userName, userPassword, redirectUrl);
String accessToken = response.getAccessToken(); // => "RlUe11faKeyCWxZToK3nk0uTKAL"

Token Refresh

When you get an access token, the response also includes a refresh token. At the end of your access token's lifetime, you can send the refresh token in a call to obtain a new access token and refresh token pair:

String refreshToken = response.getRefreshToken(); // => "d1cp20yB3hrFAKeTokenTr49EZ34kTvNK"
response = authApi.getAccessTokenUsingRefreshToken(refreshToken)

Further calls

Once you have obtained your access token you can perform any other call passing in the access token as a parameter. For example, to list the starting times of all scheduled meetings:

import com.logmein.gotogotomeeting.api;
import com.logmein.gotogotomeeting.api.model.UpcomingMeeting;
...
MeetingsApi meetingsApi = new MeetingsApi();
List<UpcomingMeeting> meetings = meetingsApi.getUpcomingMeetings(accessToken);
for (UpcomingMeeting m : meetings) {
    System.out.println(m.getStartTime());
}

Minimal Example Spring Boot Application

The following is an ultra minimal example of a Spring Boot application that lists the webinars scheduled for the next week. It assumes that you have a client ID and secret for the GoTo product you want to use with the required scopes. The example uses the GoToWebinar SDK and the GoTo Core library, to obtain a token by redirecting the user through OAuth2, call the admin API to get the account key, and then list the webinars scheduled for the next week.

package com.example;

import java.time.Instant;
import java.util.*;
import java.util.concurrent.TimeUnit;

import javax.servlet.http.HttpSession;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.view.RedirectView;

import com.logmein.gotocorelib.api.common.*;
import com.logmein.gotocorelib.api.OAuth2Api;
import com.logmein.gotowebinar.api.WebinarsApi;

@SpringBootApplication
@RestController
public class Main {
  static OAuth2Api oauth = new OAuth2Api("{provide client}", "{provide secret}");
  static WebinarsApi webinars = new WebinarsApi();
  static ApiInvoker admin = new ApiInvoker();
  static Long getAccountKey(String accessToken) throws ApiException {
      // requires 'identity:' scope
      // ref: https://developer.goto.com/admin/#operation/Get%20Me
      var data = (Map<String, Object>) admin.deserialize(
          admin.invokeAPI("https://api.goto.com", "/admin/v1/me", "GET",
              Map.of(), null,
              Map.of("Authorization", "Bearer " + accessToken), null, null),
          "", HashMap.class);

      return Long.valueOf((String) data.get("accountKey"));
  }

  public static void main(String[] args) {
    SpringApplication.run(Main.class, args);
  }

  @GetMapping("/login")
  public RedirectView login(
      @RequestParam(value = "code", required = false) String code,
      HttpSession session) throws Exception {
    if (code == null || code.isEmpty()) {
      return new RedirectView(oauth.getOAuth2AuthorizationUrl());
    }
    var tokens = oauth.getAccessTokenResponse(code);
    session.setAttribute("accessToken", tokens.getAccessToken());

    return new RedirectView("/");
  }

  @GetMapping("/")
  public ResponseEntity<?> getMyWebinars(HttpSession session) throws Exception {
    var accessToken = session.getAttribute("accessToken");

    if (accessToken == null) {
      return ResponseEntity.status(302)
          .location(java.net.URI.create("/login"))
          .build();
    }

    var accountKey = getAccountKey((String) accessToken);

    var result = webinars.getWebinars((String) accessToken, accountKey,
        Date.from(Instant.now()),
        Date.from(Instant.now().plus(7, TimeUnit.DAYS.toChronoUnit())),
        0L, 10L);

    return ResponseEntity.ok(result.getEmbedded().getWebinars());
  }
}