阿里云一键登录号码认证服务

阿里云文档:号码认证SDK_号码认证服务(PNVS)-阿里云帮助中心

对于后端大概流程 前端App会传一个token过来 后端通过下面方法解析 如果解析可以获得号码,说明号码认证成功,如果无法正确解析则认证失败

复制代码
/**
     * actoken来换取电话号码
     * @param token app端用户授权actoken
     * @return
     */
    public static String getPhone(String token) {
        DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyID, accessKeySecret);//自己阿里云的配置
        IAcsClient client =new DefaultAcsClient(profile);
        GetMobileRequest request = new GetMobileRequest();
        request.setAccessToken(token);//app端传过来的,需要用户授权拿到
        request.setSysRegionId(regionId);
        String phone = null;
        try {
            GetMobileResponse response = client.getAcsResponse(request);
            if("OK".equals(response.getCode())) {
                System.out.println(response.toString());
                phone = response.getGetMobileResultDTO().getMobile();
            };
            System.out.println(new Gson().toJson(response));
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            System.out.println("ErrCode:" + e.getErrCode());
            System.out.println("ErrMsg:" + e.getErrMsg());
            System.out.println("RequestId:" + e.getRequestId());
        }
        return phone;
    }

依赖

复制代码
<dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>aliyun-java-sdk-core</artifactId>
    <version>4.4.4</version>
</dependency>
<dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>aliyun-java-sdk-dypnsapi</artifactId>
    <version>1.0.4</version>
</dependency>
相关推荐
Full Stack Developme25 分钟前
正则表达式设计及工作原理
数据库·mysql·正则表达式
2601_9563198836 分钟前
2026年下半年AI量化学习,分清表达开发和验证
人工智能·python
云飞云共享云桌面42 分钟前
搭建10人SolidWorks云设计环境:云飞云在非标自动化工厂的实测方案
运维·服务器·网络·数据库·自动化·电脑
A-刘晨阳1 小时前
关键基础设施安全底座:自主可控时序大模型TimechoAI的国产化实践与深度时序分析能力
大数据·数据库·安全·时序数据库
深盾科技_Virbox1 小时前
Virbox Protector 从何而来:深盾科技的软件保护演进
运维·数据库·科技
CTA量化套保1 小时前
最新AI量化效率提升,用示例拆解练习压实路径
人工智能·python
zhiSiBuYu05171 小时前
混合检索实战指南:关键词与向量的完美融合
人工智能·python·机器学习
weixin_413063211 小时前
复现 MatchED 边缘检测模型(单张图片重复8次,训练200 epoch)
python·算法·计算机视觉·边缘检测模型
许彰午1 小时前
74_Python自动化办公之Excel操作
python·自动化·excel
程序员讲BPM工作流3 小时前
BPM工作流平台多租户独立数据库轻量级革新方案
数据库