第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 Google Cloud Storage 身份驗證

使用 Google Cloud Storage 身份驗證

Go
慕桂英546537 2021-11-15 17:03:29
我在服務器上運行了一個 go 應用程序。應用程序需要訪問權限才能將圖像保存到 Google Cloud Storage。從Google Cloud Storage 身份驗證文檔中可以看到如何創(chuàng)建 PKCS12 密鑰。我在用import(storage "google.golang.org/api/storage/v1")您如何在應用程序中將這個密鑰與 golang“存儲”客戶端一起使用?
查看完整描述

1 回答

?
慕運維8079593

TA貢獻1876條經(jīng)驗 獲得超5個贊

func ExampleJWTConfigFromJSON() {

    // Your credentials should be obtained from the Google

    // Developer Console (https://console.developers.google.com).

    // Navigate to your project, then see the "Credentials" page

    // under "APIs & Auth".

    // To create a service account client, click "Create new Client ID",

    // select "Service Account", and click "Create Client ID". A JSON

    // key file will then be downloaded to your computer.

    data, err := ioutil.ReadFile("/path/to/your-project-key.json")

    if err != nil {

        log.Fatal(err)

    }

    conf, err := google.JWTConfigFromJSON(data, "https://www.googleapis.com/auth/bigquery")

    if err != nil {

        log.Fatal(err)

    }

    // Initiate an http.Client. The following GET request will be

    // authorized and authenticated on the behalf of

    // your service account.

    client := conf.Client(oauth2.NoContext)

    client.Get("...")

}

--


func JWTConfigFromJSON(jsonKey []byte, scope ...string) (*jwt.Config, error)

{

    var key struct {

        Email      string `json:"client_email"`

        PrivateKey string `json:"private_key"`

    }

    if err := json.Unmarshal(jsonKey, &key); err != nil {

        return nil, err

    }

    return &jwt.Config{

        Email:      key.Email,

        PrivateKey: []byte(key.PrivateKey),

        Scopes:     scope,

        TokenURL:   JWTTokenURL,

    }, nil

}

詳情:


https://github.com/golang/oauth2/blob/master/google/example_test.go https://github.com/golang/oauth2/blob/master/google/google.go


希望這會有所幫助。


查看完整回答
反對 回復 2021-11-15
  • 1 回答
  • 0 關注
  • 242 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號