verifyProjectToken method
Asks the backend to grant the user the project's claim for the app's project token: the access, or null when it refused.
Implementation
Future<ProjectAccess?> verifyProjectToken(String userToken) async {
final response = await client.post(
Uri.parse('${config.functionsBaseUrl}/api/verifyProjectAuthToken'),
headers: {'Content-Type': 'application/json', 'Authorization': 'Bearer $userToken'},
body: jsonEncode({'token': config.authToken, 'slug': config.slug, 'clientType': config.clientType}),
);
if (response.statusCode != 200) return null;
final json = jsonDecode(response.body);
final access = ProjectAccess.fromJson(json);
if (access == null) return null;
return ProjectAccess(
projectId: access.projectId,
authToken: access.authToken.isEmpty ? config.authToken : access.authToken,
isTemplate: access.isTemplate,
timestamp: access.timestamp,
);
}