沙箱调试说明
业务用例
前置准备
https://www.xxxx.com/default.html
为例。
通过 PC 网页获取用户会员信息
步骤一:获取用户授权 auth_code
1.
https://openauth-sandbox.dl.alipaydev.com/oauth2/publicAppAuthorize.htm?app_id=APPID&scope=SCOPE&redirect_uri=ENCODED_URL
参数名 | 是否必须 | 描述 |
---|---|---|
app_id | 是 | 开发者应用的 APPID |
scope | 是 | 接口权限值,目前只支持 auth_user 和 auth_base 两个值 |
redirect_uri | 是 | 回调页面,是经过转义的 url 链接(url 必须以 http 或者 https 开头),比如:http%3A%2F%2Fexample.com 在请求之前,开发者需要先到开发者中心对应应用内,配置授权回调地址。 |
1.
https://openauth-sandbox.dl.alipaydev.com/oauth2/publicAppAuthorize.htm?app_id=2021000122650399&scope=auth_user&redirect_uri=https://www.xxxx.com/default.html
,点击进入授权页面。
2.
auth_code
。
auth_code
为:7a7da8e608dd41c39eaxxxxxxxxxxxxxxx。步骤二:通过 auth_code 换取 access_token
auth_code
作为入参传入。{
"code":"7a7da8e608dd41c39ea888940139QD01",
"grantType":"authorization_code"
}
{
"alipay_system_oauth_token_response": {
"access_token": "authusrB_D880ea78c7248ed91e292f3cb2dxxxx",
"alipay_user_id": "208872200175xxxx",
"auth_start": "2023-08-29 13:49:59",
"expires_in": 1296000,
"re_expires_in": 2592000,
"refresh_token": "authusrB_d7fb400c8d14333b856eeebf482xxxx",
"user_id": "208872200175xxxx"
}
}
步骤三:支付宝会员授权信息查询接口
auth_token
使用 步骤二 中返回的 access_token
。{
"auth_token":"authusrB_D880ea78c7248ed91e292f3cb2xxxx"
}
{
"alipay_user_info_share_response": {
"code": "10000",
"msg": "Success",
"age": "44",
"avatar": "https:\/\/tfs.alipayobjects.com\/images\/partner\/https:\/\/mdn.alipayobjects.com\/sandboxsys\/afts\/img\/AibKQZxFsLUAAAAAAAAAAAAADgSLAQBr\/original",
"cert_no": "417238197809170691",
"cert_type": "0",
"city": "资阳市",
"country_code": "CN",
"deliver_addresses": [{
"address_code": "512000",
"default_deliver_address": "F",
"deliver_city": "资阳市",
"deliver_province": "四川省"
}],
"display_name": "ookuoo7552@sandbox.com",
"email": "ookuooxxxx@sandbox.com",
"gender": "m",
"inst_or_corp": "N",
"is_blocked": "F",
"is_certified": "T",
"is_student_certified": "F",
"member_grade": "unknown",
"mobile": "10900000001",
"nick_name": "沙箱账号",
"person_birthday": "19780917",
"person_birthday_without_year": "0917",
"province": "四川省",
"user_id": "208872200175xxxx",
"user_name": "ookuoo7552",
"user_status": "T",
"user_type": "2"
}
}
通过生活号/H5获取用户会员信息
1.
auth_code
,所以不需要设置授权回调地址。