https://console.cloud.google.com/https://console.cloud.google.com/配置一個(gè)project,得到clientID、clientSecret,填寫redirect_uri:
創(chuàng)新互聯(lián)"三網(wǎng)合一"的企業(yè)建站思路。企業(yè)可建設(shè)擁有電腦版、微信版、手機(jī)版的企業(yè)網(wǎng)站。實(shí)現(xiàn)跨屏營(yíng)銷,產(chǎn)品發(fā)布一步更新,電腦網(wǎng)絡(luò)+移動(dòng)網(wǎng)絡(luò)一網(wǎng)打盡,滿足企業(yè)的營(yíng)銷需求!創(chuàng)新互聯(lián)具備承接各種類型的網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站項(xiàng)目的能力。經(jīng)過十多年的努力的開拓,為不同行業(yè)的企事業(yè)單位提供了優(yōu)質(zhì)的服務(wù),并獲得了客戶的一致好評(píng)。2.請(qǐng)求 code需要的參數(shù):
client_id
redirect_uri
response_type
scope
其中,client_id是在第一步中創(chuàng)建憑據(jù)的時(shí)候得到的,向Google 授權(quán)服務(wù)器發(fā)送如下信息則可以獲取到code
https://accounts.google.com/o/oauth2/auth?client_id=XXX&redirect_uri=XXX&scope=email&response_type=code
使用瀏覽器訪問到上面的網(wǎng)址,點(diǎn)擊確認(rèn)授權(quán)以后,則可以獲取一段
code 需要url decode?。?!
response_type = token 可直接獲取access_token
3.請(qǐng)求access token通過向Google發(fā)送post 請(qǐng)求,來獲得access token
https://accounts.google.com/o/oauth2/tokenhttps://accounts.google.com/o/oauth2/token
需要的參數(shù):POST
code = XXX
client_id = XXX
cilent_secret = XXX
redirect_uri = XXX
grant_type = authorization_code
如果成功以后,我們會(huì)收到JSON格式的Response:
{
"access_token": "xxx",
"expires_in": 3600,
"scope": "openid https://www.googleapis.com/auth/userinfo.email",
"token_type": "Bearer",
"id_token": "xxx"
}
4.使用refresh token來刷新access token當(dāng)access_token失效的時(shí)候,我們需要通過refresh_token來重新獲取。發(fā)送HTTP POST請(qǐng)求:
https://www.googleapis.com/oauth2/tokenhttps://www.googleapis.com/oauth2/v4/token
需要的參數(shù):
refresh_token = XX
client_id = XX
client_secret = XX
grant_type = XX
發(fā)送請(qǐng)求的格式如下:
POST
請(qǐng)求成功之后,會(huì)多的JOSN格式的Response,如下:
{
"access_token": "xxx",
"token_type": "Bearer",
"expires_in": 3600
}
因?yàn)榉?wù)器對(duì)refresh_token的請(qǐng)求有限制,如果過多的請(qǐng)求會(huì)導(dǎo)致請(qǐng)求失敗的情況。所以需要長(zhǎng)期保存refresh_token,只要refresh_token沒有失效,就沒有必要多次請(qǐng)求。
5. 獲取profilehttps://openidconnect.googleapis.com/v1/userinfohttps://openidconnect.googleapis.com/v1/userinfo
Header :
Authorization = Bearer ya29.****
{ "sub": "****",
"picture": "https://lh3.googleusercontent.com/****",
"email": "****",
"email_verified": true
}
Amazon官方獲取code 文檔地址:
https://developer.amazon.com/zh/docs/login-with-amazon/authorization-code-grant.htmlhttps://developer.amazon.com/zh/docs/login-with-amazon/authorization-code-grant.html
1.搭建開發(fā)環(huán)境客戶端ID:amzn1.xx
客戶端密鑰:xxxx
2.請(qǐng)求codehttps://www.amazon.com/ap/oa?client_id=***&scope=profile&response_type=code&state=email&redirect_uri=http://localhost:8080/
3.請(qǐng)求access_tokenPOST https://api.amazon.com/auth/o2/token
參數(shù) x-www-form-urlencoded
grant_type:?authorization_code
code: xxx
client_id: xxx
client_secret: xxx
redirect_uri: localhost:8080
返回:
{
"access_token": "",
"refresh_token": "",
"token_type": "bearer",
"expires_in": 3600
}
4.刷新tokenPOST https://api.amazon.com/auth/o2/token
參數(shù) x-www-form-urlencoded
grant_type:?refresh_token
client_id: xxx
client_secret: xxx
refresh_token: xxx
5.獲取profileGET https://api.amazon.com/user/profile?access_token=xxx
{
"user_id": "",
"name": "",
"email": ""
}
AppleApple Developer Documentationhttps://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_rest_api/authenticating_users_with_sign_in_with_apple
1.配置項(xiàng)client_id: xx
client_secret: jwt token形式的
Team ID: xx
key ID: xx
P8 key 私鑰:xx
redirect_uri: xx
2.請(qǐng)求code?https://appleid.apple.com/auth/authorize?response_mode=query&state=xx&response_type=code&client_id=xx&redirect_uri=xx
3.獲取tokenPOST https://appleid.apple.com/auth/token
參數(shù) x-www-form-urlencoded
grant_type:?authorization_code
code: xxx
client_id: xxx
client_secret: xxx
redirect_uri: localhost:8080
client_secret 就是自己用腳本生成的jwt token 可參考Apple Developer Documentation
{
"access_token": "",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "",
"id_token": ""
}
用戶信息通過id_token解析得出
你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級(jí)流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級(jí)服務(wù)器適合批量采購(gòu),新人活動(dòng)首月15元起,快前往官網(wǎng)查看詳情吧