Fix google and twitter examples
This commit is contained in:
parent
b8d5109744
commit
cc5efc629d
10 changed files with 39 additions and 14 deletions
|
@ -15,6 +15,7 @@
|
|||
<module name="org.twitter4j"/>
|
||||
<module name="org.jboss.logging"/>
|
||||
<module name="javax.api"/>
|
||||
<module name="javax.ws.rs.api"/>
|
||||
<module name="org.codehaus.jackson.jackson-core-asl"/>
|
||||
<module name="org.codehaus.jackson.jackson-mapper-asl"/>
|
||||
<module name="org.codehaus.jackson.jackson-xc"/>
|
||||
|
|
|
@ -34,6 +34,7 @@ documentation.
|
|||
Please take a look on [Facebook Developer Console](https://developers.facebook.com/apps/) for more details. Make sure to use the correct
|
||||
redirect URI to be used as URL on Facebook. The facebook will redirect to this URI after finish authentication. For this example, it's the URL
|
||||
[http://localhost:8080/auth/realms/facebook-identity-provider-realm/broker/facebook](http://localhost:8080/auth/realms/facebook-identity-provider-realm/broker/facebook) .
|
||||
You can also determine this redirect URI from Keycloak admin console (It's in Identity provider settings for Facebook provider).
|
||||
|
||||
Once you have a Facebook Application configured, you need to obtain both **App ID** and **App Secret** and update the
|
||||
**facebook-identity-provider-realm.json** configuration file with these information. There you'll find a section as follows:
|
||||
|
@ -127,7 +128,7 @@ create a new admin password before you can go to the create realm page.
|
|||
|
||||
[http://localhost:8080/auth/admin/master/console/#/create/realm](http://localhost:8080/auth/admin/master/console/#/create/realm)
|
||||
|
||||
Import the **facebook-identity-provider-realm.json** file that is in the saml/ example directory.
|
||||
Import the **facebook-identity-provider-realm.json** file that is in the facebook-authentication/ example directory.
|
||||
|
||||
|
||||
Start JBoss Enterprise Application Platform 6 or WildFly with the Web Profile
|
||||
|
|
|
@ -31,9 +31,9 @@ Make sure you've set up a application in Google
|
|||
This example application requires you to create a Google Application. How to create it is beyond the scope of this
|
||||
documentation.
|
||||
|
||||
Please take a look on [Google Developer Console](https://developers.google.com/apps/) for more details.
|
||||
Please take a look on [Google Developer Console](https://cloud.google.com/console/project) for more details.
|
||||
|
||||
Once you have a Google Application configured, you need to obtain both **App ID** and **App Secret** and update the
|
||||
Once you have a Google Application configured, you need to obtain both **Client ID** and **Client Secret** and update the
|
||||
**google-identity-provider-realm.json** configuration file with these information. There you'll find a section as follows:
|
||||
|
||||
"identityProviders": [
|
||||
|
@ -51,7 +51,11 @@ Once you have a Google Application configured, you need to obtain both **App ID*
|
|||
}
|
||||
]
|
||||
|
||||
Please, update both *clientId* and *clientSecret* configuration options with the **App ID** and **App Secret**.
|
||||
Please, update both *clientId* and *clientSecret* configuration options with the **Client ID** and **Client Secret**.
|
||||
|
||||
Make sure to use the correct redirect URI to be used as URL on Google. The Google will redirect to this URI after finish authentication. For this example, it's the URL
|
||||
[http://localhost:8080/auth/realms/google-identity-provider-realm/broker/google](http://localhost:8080/auth/realms/google-identity-provider-realm/broker/google) .
|
||||
You can also determine the redirect URI from Keycloak admin console (It's in Identity provider settings for Google provider).
|
||||
|
||||
Make sure you've set up the Keycloak Server
|
||||
--------------------------------------
|
||||
|
@ -125,7 +129,7 @@ create a new admin password before you can go to the create realm page.
|
|||
|
||||
[http://localhost:8080/auth/admin/master/console/#/create/realm](http://localhost:8080/auth/admin/master/console/#/create/realm)
|
||||
|
||||
Import the **google-identity-provider-realm.json** file that is in the saml/ example directory.
|
||||
Import the **google-identity-provider-realm.json** file that is in the google-authentication/ example directory.
|
||||
|
||||
|
||||
Start JBoss Enterprise Application Platform 6 or WildFly with the Web Profile
|
||||
|
|
|
@ -42,6 +42,12 @@
|
|||
],
|
||||
"webOrigins": [
|
||||
"http://localhost:8080"
|
||||
],
|
||||
"identityProviders": [
|
||||
{
|
||||
"id": "google",
|
||||
"retrieveToken": true
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
|
@ -83,7 +83,7 @@ module.controller('GlobalCtrl', function($scope, $http, $location, Auth) {
|
|||
$scope.identity = Auth.getIdentity();
|
||||
|
||||
$scope.loadSocialProfile = function() {
|
||||
$http.get('http://localhost:8081/auth/realms/google-identity-provider-realm/broker/google/token').success(function(data) {
|
||||
$http.get('/auth/realms/google-identity-provider-realm/broker/google/token').success(function(data) {
|
||||
var accessToken = data.access_token;
|
||||
|
||||
var req = {
|
||||
|
|
|
@ -31,9 +31,9 @@ Make sure you've set up a application in Twitter
|
|||
This example application requires you to create a Twitter Application. How to create it is beyond the scope of this
|
||||
documentation.
|
||||
|
||||
Please take a look on [Twitter Developer Console](https://developers.twitter.com/apps/) for more details.
|
||||
Please take a look on [Twitter Developer Console](https://dev.twitter.com/apps) for more details.
|
||||
|
||||
Once you have a Twitter Application configured, you need to obtain both **App ID** and **App Secret** and update the
|
||||
Once you have a Twitter Application configured, you need to obtain both **Consumer Key** and **Consumer Secret** and update the
|
||||
**twitter-identity-provider-realm.json** configuration file with these information. There you'll find a section as follows:
|
||||
|
||||
"identityProviders": [
|
||||
|
@ -51,7 +51,7 @@ Once you have a Twitter Application configured, you need to obtain both **App ID
|
|||
}
|
||||
]
|
||||
|
||||
Please, update both *clientId* and *clientSecret* configuration options with the **App ID** and **App Secret**.
|
||||
Please, update both *clientId* and *clientSecret* configuration options with the **Consumer Key** and **Consumer Secret**.
|
||||
|
||||
Make sure you've set up the Keycloak Server
|
||||
--------------------------------------
|
||||
|
@ -125,7 +125,7 @@ create a new admin password before you can go to the create realm page.
|
|||
|
||||
[http://localhost:8080/auth/admin/master/console/#/create/realm](http://localhost:8080/auth/admin/master/console/#/create/realm)
|
||||
|
||||
Import the **twitter-identity-provider-realm.json** file that is in the saml/ example directory.
|
||||
Import the **twitter-identity-provider-realm.json** file that is in the twitter-authentication/ example directory.
|
||||
|
||||
|
||||
Start JBoss Enterprise Application Platform 6 or WildFly with the Web Profile
|
||||
|
@ -156,7 +156,10 @@ _NOTE: The following build command assumes you have configured your Maven user s
|
|||
Access the application
|
||||
---------------------
|
||||
|
||||
The application will be running at the following URL: <http://localhost:8080/twitter-authentication>.
|
||||
The application will be running at the following URL: <http://localhost:8080/twitter-authentication/index.html>. This is angular based application.
|
||||
In addition, the example contains testing servlet, which will show you JSON with full info about your Twitter account. Servlet is accessible
|
||||
on [http://localhost:8080/twitter-authentication/twitter/showUser](http://localhost:8080/twitter-authentication/twitter/showUser) .
|
||||
|
||||
|
||||
|
||||
Undeploy the Archive
|
||||
|
|
|
@ -67,6 +67,11 @@ public class TwitterShowUserServlet extends HttpServlet {
|
|||
initKeyCloakClient(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
this.keycloak.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doGet(final HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
TwitterOAuthResponse twitterOAuthResponse = getTwitterOAuthResponse(request);
|
||||
|
@ -132,6 +137,5 @@ public class TwitterShowUserServlet extends HttpServlet {
|
|||
this.keycloak = Keycloak.getInstance(authServer, realmName, "admin", "password", "admin-client", "password");
|
||||
IdentityProvidersResource providersResource = keycloak.realm(realmName).identityProviders();
|
||||
this.identityProvider = providersResource.get("twitter").toRepresentation();
|
||||
this.keycloak = Keycloak.getInstance(authServer, realmName, "admin", "password", "admin-client", "password");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"realm" : "twitter-identity-provider-realm",
|
||||
"resource" : "twitter-authentication",
|
||||
"realm-public-key" : "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB",
|
||||
"auth-server-url": "/auth",
|
||||
"auth-server-url": "http://localhost:8080/auth",
|
||||
"ssl-required" : "external",
|
||||
"public-client" : true
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ module.controller('GlobalCtrl', function($scope, $http, $location, Auth) {
|
|||
$scope.identity = Auth.getIdentity();
|
||||
|
||||
$scope.loadSocialProfile = function() {
|
||||
$http.get('http://localhost:8080/twitter-authentication/twitter/showUser')
|
||||
$http.get('/twitter-authentication/twitter/showUser')
|
||||
.success(function(profile) {
|
||||
$scope.socialProfile = profile;
|
||||
})
|
||||
|
|
|
@ -43,6 +43,12 @@
|
|||
],
|
||||
"webOrigins": [
|
||||
"http://localhost:8080"
|
||||
],
|
||||
"identityProviders": [
|
||||
{
|
||||
"id": "twitter",
|
||||
"retrieveToken": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue