栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

大部分情况下,使用client4 go驱动程序使用个人访问令牌登录的正式方法是什么?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

大部分情况下,使用client4 go驱动程序使用个人访问令牌登录的正式方法是什么?

关键是 登录,设置个人访问令牌并调用client.GetMe。通过查看python驱动程序源代码后,这一点变得很清楚。相关的片段是。

    fmt.Println("LoginAsTheBotUser", "Using personal access token")    client.AuthToken = mattermost_personal_access_token    client.AuthType = model.HEADER_TOKEN    if user, resp := client.GetMe(""); resp.Error != nil {        println("There was a problem logging into the Mattermost server.  Are you sure the access token is valid?")        PrintError(resp.Error)    } else {        fmt.Println(client)        botUser = user        result = true    }

上下文。

func LoginAsTheBotUser() bool {    fmt.Println("LoginAsTheBotUser")    fmt.Println("LoginAsTheBotUser", time.Now())    var result bool = false    if mattermost_personal_access_token == "" {        fmt.Println("LoginAsTheBotUser", "Getting access token from login with username and password")        if user, resp := client.Login(mattermost_user_email, mattermost_user_password); resp.Error != nil { println("There was a problem logging into the Mattermost server.  Are you sure ran the setup steps from the README.md?") PrintError(resp.Error)        } else { fmt.Println(client) botUser = user result = true        }    } else {        fmt.Println("LoginAsTheBotUser", "Using personal access token")        client.AuthToken = mattermost_personal_access_token        client.AuthType = model.HEADER_TOKEN        if user, resp := client.GetMe(""); resp.Error != nil { //if user, resp := client.Login(mattermost_personal_access_token); resp.Error != nil { println("There was a problem logging into the Mattermost server.  Are you sure the access token is valid?") PrintError(resp.Error)        } else { fmt.Println(client) botUser = user result = true        }    }    fmt.Println("LoginAsTheBotUser", time.Now())    fmt.Println("LoginAsTheBotUser")    return result}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/375683.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号