I'm trying to Issue a Google Wallet pass to a user. I believe I'm having an issue with the authentication portion of this code.
On the last line when executing the request, I keep receiving this error:
Google.Apis.Requests.RequestError
header must be set [400]
Errors [
Message[header must be set] Location[ - ] Reason[invalidResource] Domain[walletobjects]
]
// Create the Google Wallet API service
var credential = GoogleCredential.FromFile(@"E:\\myCreds.json")
.CreateScoped(new List<string>
{
WalletobjectsService.ScopeConstants.WalletObjectIssuer
}).UnderlyingCredential;
// Create the Google Wallet API service
var service = new WalletobjectsService(new Google.Apis.Services.BaseClientService.Initializer
{
HttpClientInitializer = credential
});
// Create a new Generic pass object
var genericObject = new GenericObject
{
Id = $"{_issuerId}.{Guid.NewGuid()}",
ClassId = _passClass,
State = "ACTIVE",
HeroImage = new Image
{
SourceUri = new ImageUri
{
Uri = String.IsNullOrEmpty(request.ImageUrl) ? "https://storage.googleapis.com/wallet-lab-tools-codelab-artifacts-public/google-io-hero-demo-only.png" : request.ImageUrl
}
},
CardTitle = new LocalizedString
{
DefaultValue = new TranslatedString
{
Language = "en-US",
Value = request.Title
}
},
Barcode = new Barcode
{
Type = "CODE_39",
Value = request.BarcodeValue
}
};
// Insert the pass object
var genericObjectResponse = service.Genericobject.Insert(genericObject).Execute();