2017-08-23 50 views
0

我有JAX-RS资源,并使用keycloak 我想要得到的令牌邮差Keycloak JAX-RS和邮差授权(AUTH URL)

这是JAX-RS(keycloak-快速入门的数据库客户端)

{ 
    "realm": "demo", 
    "bearer-only": true, 
    "auth-server-url": "http://localhost:8080/auth", 
    "ssl-required": "external", 
    "resource": "database-service" 
} 

我创建了一个客户端邮差

{ 
    "realm": "demo", 
    "auth-server-url": "http://localhost:8080/auth", 
    "ssl-required": "external", 
    "resource": "client-postman", 
    "credentials": { 
    "secret": "b53f32d3-e15b-474b-a88d-1f1cfa68c2dc" 
    } 
} 

我选择的OAuth 2.0类型 enter image description here

的访问令牌的网址是

http://localhost:8080/auth/realms/demo/protocol/openid-connect/token 

但我不知道是什么验证网址enter image description here

+1

得到这些网址看看[此帖](http://blog.keycloak.org/2015/10/getting-started-with-keycloak-securing.html) - 滚动直到“获取令牌和调用服务”。 – stdunbar

+0

谢谢,但我知道如何通过代码获取令牌,我不知道如何通过邮递员来完成 – Pako

+1

我链接的帖子使用'curl'来解释它,但它的想法是一样的。要致电您的服务,您需要一个'Authorization'标头。不要忘记“持票人”部分。 – stdunbar

回答

0

我设法接收令牌,但我不知道该怎么称呼在JAX-RS资源

我将它设置在keycloak:

Direct Access Grants Enabled: ON 
Service Accounts Enabled : ON 

enter image description here

和邮递员要求 enter image description here

现在,我有令牌,我可以通过设置JAXRS URL和头授权调用资源:承载[我的令牌]

enter image description here

现在我想使用邮差的授权功能来加快步骤和调用资源目录ectly,但我不知道这是否是可能

+0

如何管理设置令牌从键盘时钟 –

+0

@ShubhamJain我不明白的问题 – Pako

+0

我的申请是得到auth来自关键时钟的令牌..由于我在邮递员测试中卡住登录本身,因为邮递员不允许导入额外的包..你如何处理这种情况 –

0

与邮差的当前版本和keycloak 2.2.1.Final我已经成功地建立的OAuth 2.0

Postman setup for keycloak

客户秘密:realm-public-key从安装JSON

Auth Url:https://{KEYCLOAK}/auth/realms/{REALM}/protocol/openid-connect/auth

令牌网址:https://{KEYCLOAK}/auth/realms/{REALM}/protocol/openid-connect/token

您可以从 https://{KEYCLOAK}/auth/realms/{REALM}/.well-known/openid-configuration