一個功能完整的OAuth2服務器插件,為您的Emlog網(wǎng)站提供OAuth2.0授權服務,支持其他應用使用您的網(wǎng)站賬號進行單點登錄。
啟用插件后,您的網(wǎng)站將提供以下OAuth2端點:
https://yoursite.com/?plugin=oauth2_server&action=authorizehttps://yoursite.com/?plugin=oauth2_server&action=tokenhttps://yoursite.com/?plugin=oauth2_server&action=userinfohttps://yoursite.com/?plugin=oauth2_server&action=user_auth重定向到授權頁面:
https://yoursite.com/?plugin=oauth2_server&action=authorize
&response_type=code
&client_id=YOUR_CLIENT_ID
&redirect_uri=YOUR_CALLBACK_URL
&scope=profile email
&state=RANDOM_STATE
交換訪問令牌:
curl -X POST https://yoursite.com/?plugin=oauth2_server&action=token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=authorization_code" \
-d "code=AUTHORIZATION_CODE" \
-d "redirect_uri=YOUR_CALLBACK_URL" \
-d "client_id=YOUR_CLIENT_ID" \
-d "client_secret=YOUR_CLIENT_SECRET"
獲取用戶信息:
curl -H "Authorization: Bearer ACCESS_TOKEN" \
https://yoursite.com/?plugin=oauth2_server&action=userinfo
profile - 用戶基本信息(昵稱、頭像等)email - 用戶郵箱地址在插件設置頁面可以配置: