Unfortunately, you can't get the vanityName
easily in v2, unless you apply for partnership program (as what KPSingh suggested) but LinkedIn discourages you to apply the partnership if you only want to get the vanityName
.
https://learn.microsoft.com/en-us/linkedin/shared/integrations/people/profile-api-v1-migration
Please do not apply to a partner program like the Marketing Developer Platform if you are seeking access to member profile data that is not made available via the new “Lite Profile” permission. Access to partner programs is appropriate for select use cases only, and all other requests for access will be rejected.
Also, in v2 r_basicprofile
was replaced with r_liteprofile
permission.