Skip to content

freddyboucher/gwt-oauth2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gwt-oauth2

Live demo: https://gwt-oauth2.appspot.com/

Quick start

1. Add the Maven dependency

<dependency>
  <groupId>io.github.freddyboucher</groupId>
  <artifactId>gwt-oauth2</artifactId>
  <version>1.2</version>
  <scope>provided</scope>
</dependency>

2. Add <inherits name="io.github.freddyboucher.gwt.oauth2.OAuth2"/> to your GWT module XML file.

3. Use it as follow:

public class App implements EntryPoint {
  @Override
  public void onModuleLoad() {
    Button button = new Button("Google", (ClickHandler) event -> {
      AuthRequest req =
          new AuthRequest("https", "accounts.google.com", "o/oauth2/auth", "GOOGLE_CLIENT_ID")
              .setParameter("scope", "email profile openid");
      Auth.get().login(req, new Callback<Map<String, String>, Throwable>() {
        @Override
        public void onFailure(Throwable reason) {
          GWT.log(null, reason);
        }

        @Override
        public void onSuccess(Map<String, String> result) {
          String token = result.get("access_token");
          GWT.log(token);
        }
      }, "access_token");
    });
    RootPanel.get().add(button);
  }
}

Release Notes

  • 1.2
    • Fix: Deal with issue that oauth window cannot access parent window custom JS by switching to window.postMessage (as a result, you do not need to add the generateJsInteropExports compilation option to your project anymore).
  • 1.1
    • Fix: Avoid Google api.js name collision by renaming oauth2 to gwtOAuth2
  • 1.0
    • Expose TokenStore and add TokenStore#keySet and TokenStore#remove
  • 1.0-RC2
    • Fix: Uncaught TypeError: Cannot set property 'innerText' of null
    • Add 'viewport' meta to have a readable message on Mobile device
  • 1.0-RC1
    • Update GWT to 2.9.0
    • Migrate JSNI to JsInterop / elemental2
  • 0.5
    • Map<String, String> result - values are still URL encoded #10
  • 0.4
    • Map<String, String> result - values are URL encoded #8
    • Callback is never consumed when manually closing the login window #9
  • 0.3
    • Initial release

Contributing

Code must pass Google Java Style Guide.

About

OAuth 2.0 Library for GWT (Google Web Toolkit)

Resources

License

Stars

Watchers

Forks

Packages

No packages published