0

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();

1 Answer 1

0

Well, this was silly. I didn't realize it at first, but there was actually a header property in the posted object which it wanted defined and accepts a localizedString. Seems to be similar to the title so I just set it to what the title has for now and it works.

Now I have another issue! With an active pass returned and its id, I can generate a wallet pass url to add to wallet: https://pay.google.com/gp/v/save/{pass.Id}

However, this page only says "Something went wrong. Please try again."

Closest thing I could find is that my email account doing the testing in demo mode needs to be either added as an admin user to the pay & wallet account and/or a test user under the wallet api. I have added it to both with no luck.

Not the answer you're looking for? Browse other questions tagged or ask your own question.