@@ -36,7 +36,7 @@ var JWKSUrl = "https://firebaseappcheck.googleapis.com/v1beta/jwks"
3636
3737const appCheckIssuer = "https://firebaseappcheck.googleapis.com/"
3838
39- const tokenVerificationUrlFormat = "https://firebaseappcheck.googleapis.com/v1beta/projects/%s:verifyAppCheckToken "
39+ const tokenVerifierBaseUrl = "https://firebaseappcheck.googleapis.com"
4040
4141var (
4242 // ErrIncorrectAlgorithm is returned when the token is signed with a non-RSA256 algorithm.
@@ -72,9 +72,9 @@ type DecodedAppCheckToken struct {
7272
7373// Client is the interface for the Firebase App Check service.
7474type Client struct {
75- projectID string
76- jwks * keyfunc.JWKS
77- tokenVerificationUrl string
75+ projectID string
76+ jwks * keyfunc.JWKS
77+ tokenVerifierUrl string
7878}
7979
8080// NewClient creates a new instance of the Firebase App Check Client.
@@ -92,9 +92,9 @@ func NewClient(ctx context.Context, conf *internal.AppCheckConfig) (*Client, err
9292 }
9393
9494 return & Client {
95- projectID : conf .ProjectID ,
96- jwks : jwks ,
97- tokenVerificationUrl : fmt . Sprintf ( tokenVerificationUrlFormat , conf .ProjectID ),
95+ projectID : conf .ProjectID ,
96+ jwks : jwks ,
97+ tokenVerifierUrl : buildTokenVerifierUrl ( conf .ProjectID ),
9898 }, nil
9999}
100100
@@ -212,7 +212,7 @@ func (c *Client) VerifyOneTimeToken(token string) (*DecodedAppCheckToken, error)
212212
213213 bodyReader := bytes .NewReader ([]byte (fmt .Sprintf (`{"app_check_token":%s}` , token )))
214214
215- resp , err := http .Post (c .tokenVerificationUrl , "application/json" , bodyReader )
215+ resp , err := http .Post (c .tokenVerifierUrl , "application/json" , bodyReader )
216216
217217 if err != nil {
218218 return nil , err
@@ -235,6 +235,10 @@ func (c *Client) VerifyOneTimeToken(token string) (*DecodedAppCheckToken, error)
235235 return decodedAppCheckToken , nil
236236}
237237
238+ func buildTokenVerifierUrl (projectId string ) string {
239+ return fmt .Sprintf ("%s/v1beta/projects/%s:verifyAppCheckToken" , tokenVerifierBaseUrl , projectId )
240+ }
241+
238242func contains (s []string , str string ) bool {
239243 for _ , v := range s {
240244 if v == str {
0 commit comments