The authorization code (aka 'auth code') is the registrant’s password for their domain name, which is used to complete a change of registrar.
The code is generated by the registrar on the registrant’s request. The registrar is obligated to produce an authorization code for every domain name that the registrar administers at any time on the request of the registrant. After use, the code is forfeit.
Information about authorization codes in EPP is described in the EPP manual. Current EPP documentation is available for download on the registrar website, registry.se
A common procedure is to allow the user to generate the code by clicking on a button in the registrars control panel. Offering this function in a control panel also resolves the issue of authentication and ensuring that only the registrant has access to it. After use, the code is forfeit.