Created
July 20, 2017 13:39
-
-
Save thomasdarimont/ca16080145d226e50628d5696ffb9508 to your computer and use it in GitHub Desktop.
Simple Authentication for Desktop apps with Keycloak.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"realm": "local-user-import", | |
"auth-server-url": "http://192.168.99.1:8080/u/auth", | |
"ssl-required": "external", | |
"resource": "app-edrewe", | |
"credentials": { | |
"secret": "29ddfb71-53fa-446d-aed5-2ce6de1fe490" | |
}, | |
"use-resource-role-mappings": true | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package demo; | |
import org.keycloak.adapters.installed.KeycloakInstalled; | |
import org.keycloak.representations.AccessToken; | |
public class Main { | |
public static void main(String[] args) throws Exception { | |
KeycloakInstalled keycloak = new KeycloakInstalled(); | |
keycloak.loginDesktop(); | |
System.out.println("Logged in..."); | |
AccessToken token = keycloak.getToken(); | |
System.out.printf("UserId: %s%n", token.getSubject()); | |
System.out.printf("Username: %s%n", token.getPreferredUsername()); | |
System.out.printf("Email: %s%n", token.getEmail()); | |
System.out.println(keycloak.getTokenString()); | |
System.in.read(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment