*UPDATE*: developer token is missing How I should set it?
On Wednesday, March 11, 2020 at 2:35:51 PM UTC-3, Federico Extramiana wrote: > > Hello, > > I'm trying to integrete with google adds using Go and gprc (using google's > generated libraries) > > I'm making a request to get a campaign but it always > returns InvalidArgument, I'd tried almost anything > > I tried to use Rest api (same credentials, same resources) and worked > > Does anyone knows whats going on?? > > the code: > > func getClient() *grpc.ClientConn { > token := oauth2.Token{ > AccessToken: "MyAccessToken", > TokenType: "Bearer", > RefreshToken: "MyToken", > Expiry: time.Now(), > } > > config := oauth2.Config{ > ClientID: "MyClientID", > > ClientSecret: "MyClientSecret", > > Endpoint: google.Endpoint, > Scopes: []string{"https://www.googleapis.com/auth/adwords"}, > } > > tokenSource := config.TokenSource(context.Background(), &token) > > t, err := tokenSource.Token() > if err != nil { > fmt.Println(err) > return nil > } > perRPC := oauth.NewOauthAccess(t) > > // TSL credentials > pool, err := x509.SystemCertPool() > if err != nil { > fmt.Println(err) > return nil > } > creds := credentials.NewClientTLSFromCert(pool, "") > > // client init > connection, err := grpc.Dial( > "googleads.googleapis.com:443", > grpc.WithPerRPCCredentials(perRPC), > grpc.WithTransportCredentials(creds), > ) > > if err != nil { > fmt.Println(err) > return nil > } > > return connection > } > > > func getCampaign() { > service := googleads.NewCampaignServiceClient(getClient()) > > // request > headers := make(metadata.MD) > headers["developer-token"] = []string{"my-developer-token"} > > header := grpc.CallOption(grpc.HeaderCallOption{HeaderAddr: &headers}) > request := &googleads.GetCampaignRequest{ResourceName: > "customers/1234567890/campaigns/123456789} // I faked the ids > > // call > response, err := service.GetCampaign(context.Background(), request, header) > if err != nil { > fmt.Println(err) > return > } > > fmt.Println(response, err) > } > > -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog: https://googleadsdeveloper.blogspot.com/ =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups "AdWords API and Google Ads API Forum" group. To post to this group, send email to adwords-api@googlegroups.com To unsubscribe from this group, send email to adwords-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en --- You received this message because you are subscribed to the Google Groups "AdWords API and Google Ads API Forum" group. To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/eb2a66df-e681-460e-9d83-5f18b01d8f24%40googlegroups.com.