Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共5 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:华为云物联网token怎么获取

1楼
xyfjhgf 发表于:2025/4/24 23:32:00
怎么获取token?请大家提示一下,谢谢
2楼
xyfjhgf 发表于:2025/4/24 23:44:00
这是文档
3楼
xyfjhgf 发表于:2025/4/27 8:38:00
应该是成功了
4楼
xyfjhgf 发表于:2025/4/27 8:39:00
Static CreateTime As Date '记录最近一次生成access_token的时间
Static AccessTocken As String '记录最近一次生成的access_token

Dim Name As String = "********" '用户名
Dim PassWord As String = "********" '密码
Dim DomainName As String = "********" '账号名
Dim ScopeProjectName As String = "********" '项目


Dim tp As TimeSpan = Date.Now - CreateTime
Dim url As String = "https://iam.cn-north-4.myhuaweicloud.com/v3/auth/tokens"
Dim json As String = "{""auth"":{""identity"":{""methods"":[""password""],""password"":{""user"":{""name"":""{0}"",""password"":""{1}"",""domain"":{""name"":""{2}""}}}},""scope"":{""project"":{""name"":""{3}""}}}}"
If tp.TotalSeconds > 3600 Then
    Dim hc As New HttpClient(url)
    hc.Headers.Add("Content-Type", "application/json;charset=utf-8")
    hc.Content = CExp(json, Name, PassWord, DomainName, ScopeProjectName)
    
    '****获取头信息
    Dim retH As String = hc.GetInformation()
    If retH = "" Then '如果失败,再尝试一次
        hc.GetInformation()
    End If
    
    '****获取返回的信息
    Dim ret As String = hc.GetData()
    If ret = "" Then '如果失败,再尝试一次
        hc.GetData()
    End If
    Dim jo As JObject = JObject.Parse(ret)
    If jo("errcode") Is Nothing Then
        AccessTocken = hc.ResponseHeaders("X-Subject-Token")
        Output.Show("AccessTocken:" & AccessTocken)
    Else
        MessageBox.show("获取access_token失败,原因:" & vbcrlf & jo("errmsg").ToString)
    End If
    
End If
Return AccessTocken
共5 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .03320 s, 2 queries.