V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
mywget
V2EX  ›  Go 编程语言

有用过 azure-sdk-for-go 的么, 请问认证授权怎么弄啊!

  •  
  •   mywget · 2020-12-29 02:23:30 +08:00 · 1355 次点击
    这是一个创建于 1185 天前的主题,其中的信息可能已经有所发展或是发生改变。

    卡在认证这一步了, 想来操作 vm

    5 条回复    2020-12-30 17:34:47 +08:00
    Itoktsnhc
        1
    Itoktsnhc  
       2020-12-29 10:42:58 +08:00
    go 的没用过,.net 的需要在 azure 上新建一个 AD 应用 然后通过这个应用的名称 /租户名称 /密码这些东西来权限认证,看了下 go 的 sample 也很像:
    Itoktsnhc
        2
    Itoktsnhc  
       2020-12-29 10:43:46 +08:00
    https://github.com/Azure-Samples/azure-sdk-for-go-samples:

    To use service principal authentication, create a principal by running az ad sp create-for-rbac -n "<yourAppName>" and set the following environment variables. You can copy .env.tpl to a .env file in each package for ease of use.

    export AZURE_SUBSCRIPTION_ID=
    export AZURE_TENANT_ID=
    export AZURE_CLIENT_ID=
    export AZURE_CLIENT_SECRET=

    export AZURE_LOCATION_DEFAULT=westus2
    export AZURE_BASE_GROUP_NAME=azure-samples-go
    export AZURE_KEEP_SAMPLE_RESOURCES=0
    Itoktsnhc
        3
    Itoktsnhc  
       2020-12-29 10:45:19 +08:00
    mywget
        4
    mywget  
    OP
       2020-12-30 17:09:25 +08:00
    @Itoktsnhc 我看过这个, 但是他把认证函数都封装在内部了, 我想把它抽出来, 能力不够被绕晕了, 我用过 python 的认证比 go 的好很多
    Itoktsnhc
        5
    Itoktsnhc  
       2020-12-30 17:34:47 +08:00
    @mywget 嗯 需要提供一个 Service principal 就行
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3215 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 13:08 · PVG 21:08 · LAX 06:08 · JFK 09:08
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.