awa/go-iap

Cannot get token from ParseNotificationV2 func

Closed this issue · 7 comments

here is the case

import (
	"time"

	"github.com/awa/go-iap/appstore"
	"github.com/golang-jwt/jwt/v4"
)

// it is too long, i make short here
var signedPayload  = `eyJhbGciOiJFUzI1...`

func main() {
	token := &jwt.Token{}
	if err := appstore.New().ParseNotificationV2(signedPayload, token); err != nil {
		panic(err)
	}
}

and no matter token is a struct or pointer, just cannot be parsed.

image

but actually in ParseNotificationV2 there are not empty

image

richzw commented

Is there any error returned from ParseNotificationV2?

no, is the token always be empty

and i have made a pr to fix that, could @richzw help me to review? thx~

MakDon commented

IMHO, it is better that use ParseNotificationV2(tokenStr string) (result *jwt.Token, err error) as the method signature.

richzw commented

IMHO, it is better that use ParseNotificationV2(tokenStr string) (result *jwt.Token, err error) as the method signature.

Yes, It could be better to use ParseNotificationV2(tokenStr string) (result *jwt.Token, err error). To use this method ParseNotificationV2(tokenStr string, result *jwt.Token) error just follow the same signature of Verify and VerifyWithStatus

richzw commented

and i have made a pr to fix that, could @richzw help me to review? thx~

Thank you very much for your help. I will review your PR ASAP

It is ok right now~

image

Thanks for support @richzw
So quick👍