Commit 32419e22 authored by Mo Firouz's avatar Mo Firouz
Browse files

Various fixes for Google IAP

parent 4c9a8aa6
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ function M.verify_payment_apple(request)
end

function M.google_obtain_access_token(client_email, private_key)
  local auth_url = "https://accounts.google.com/o/oauth2/auth"
  local auth_url = "https://accounts.google.com/o/oauth2/token"
  local scope = "https://www.googleapis.com/auth/androidpublisher"
  local exp = nk.time() + 3600000 -- current time + 1hr added in ms
  local iat = nk.time()
@@ -95,7 +95,7 @@ function M.google_obtain_access_token(client_email, private_key)

  local jwt_token = nk.jwt_generate(algo_type, private_key, jwt_claimset)

  local grant_type = "urn%3ietf%3params%3oauth%3grant-type%3jwt-bearer"
  local grant_type = "urn:ietf:params:oauth:grant-type:jwt-bearer"
  local form_data = "grant_type=" .. grant_type .. "&assertion=" .. jwt_token
  local http_headers = {
    ["Content-Type"] = "application/x-www-form-urlencoded",
+6 −1
Original line number Diff line number Diff line
@@ -741,7 +741,12 @@ func (n *RuntimeLuaNakamaModule) jwtGenerate(l *lua.LState) int {
	}

	token := jwt.NewWithClaims(signingMethod, jwtClaims)
	signedToken, _ := token.SignedString([]byte(signingKey))
	signedToken, err := token.SignedString([]byte(signingKey))
	if err != nil {
		l.RaiseError("failed to sign token: %v", err.Error())
		return 0
	}

	l.Push(lua.LString(signedToken))
	return 1
}