Best practices for populating user field via a link?

I want users to be able to click a link containing their user ID in a different application so that it can be stored in their Discourse profile. For example, https://discourse.example.com/script?uid=1

It’s a simple idea: click a link to authenticate in Discourse (if not already logged in), then store the value for uid in a Discourse user field.

I could also use a form if PUT is required over GET. Any idea what the best practice would be for achieving this?