I have written a GO code to authorize and retrieve a token for admin using web account and i am able to list the user of my domain using Admin SDK.
But what i have to do now is access users mailbox in my domain.
Here is my code and error i got.
func userGmail(){
baseUrl := "
https://www.googleapis.com/gmail/v1/users/us...@domain.com/threads"
authbear := "Bearer "
authbear += <Access_token>
cli := &http.Client{}
req, err := http.NewRequest("GET", baseUrl, nil)
if(err!=nil){
fmt.Println(err)
}
req.Header.Set("Authorization", authbear)
res, err := cli.Do(req)
if(err!=nil){
fmt.Println(err)
}
re, err := ioutil.ReadAll(res.Body)
if(err!=nil){
fmt.Println(err)
}
fmt.Println(string(re))
}
{
"error": {
"errors": [
{
"domain": "global",
"reason": "forbidden",
"message": "Delegation denied for <
us...@domain.com>"
}
],
"code": 403,
"message": "Delegation denied for <
us...@domain.com>"
}
}