小编Pra*_*sad的帖子

用于检索谷歌+域名配置文件的Golang程序返回403 Forbidden

你可以帮我解决下面的问题.

我只是编写一个简单的代码来检索我的谷歌+域用户配置文件.1.我正在使用域名为spaceandhow.com的谷歌+域帐户

  1. 我已提供https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority中列出的所有权限

  2. 该帐户已启用Google+ API和Google+域Api.

这是我写的功能.

func (p *GoogleAUTH) sendGoogleAuthReq(){

    fmt.Println("GoogleAUTH package: Enter sendGoogleAuthReq")


    data, err := ioutil.ReadFile("D:\\Cygwin\\home\\praprasa\\pragna2.json")
    if err != nil {
        fmt.Printf("ReadFile error: %s", err)
    }


    conf, err := google.JWTConfigFromJSON(data, "https://www.googleapis.com/auth/plus.me")
    if err != nil {
        fmt.Println("json error")

    }

    client := conf.Client(oauth2.NoContext)

    resp, err := client.Get("https://www.googleapis.com/plusDomains/v1/people/me")
    if err != nil {
        fmt.Printf("GoogleAUTH package: request execution failed: %s", err)
        return
    }
    defer resp.Body.Close()

    fmt.Println("GoogleAUTH package: response Status:", resp.Status)
    fmt.Println("GoogleAUTH package: response Headers:", resp.Header)

    body, err := ioutil.ReadAll(resp.Body) …
Run Code Online (Sandbox Code Playgroud)

download go user-profile http-status-code-403 google-domain-api

5
推荐指数
1
解决办法
238
查看次数