FX-HAO / keycloak-phone-authenticator

Obtain token and reset password via SMS
130 stars 43 forks source link

怎样通过验证码和电话号通过rest api 登录并得到 oauth access token 呢? #2

Closed cooperlyt closed 3 years ago

cooperlyt commented 3 years ago

你好:

curl -X POST \ http://localhost:8081/auth/realms/$YOUR_REALM/protocol/openid-connect/token \ -H 'authorization: Basic c2h1bmRhby1hZG1pbjoxODc3MGYxMi02NjE4LTQwOTctYThmYi1kMjA0Mzg0Mzg4OTk=' \ -H 'content-type: application/x-www-form-urlencoded' \ -d 'grant_type=password&phone_number=$PHONE_NUMBER&code=$VERIFICATION_CODE'

此例中 authorization 是什么? 是怎么得来的? 另外参数中没有指定 client_id ?

是要把 client 的 Access Type 设置为 confidential , 先取得client 的 token 再运行这个吗?

cooperlyt commented 3 years ago

oh! just use this:

curl -X POST http://localhost:8081/auth/realms/$YOUR_REALM/protocol/openid-connect/token -H 'content-type: application/x-www-form-urlencoded' -d 'grant_type=password&phone_number=$PHONE_NUMBER&code=$VERIFICATION_CODE&client_id=$CLIENT_ID&client_secret=CLIENT_SECRECT'

client Access Type : confidential Service Accounts Enabled: on Authentication Flow Overrides - Direct Grant Flow: Direct grant with phone

in Keycloak 10.0.2