#Core API Walkthrough
##How the API works internally
When you register an application in Core, an [Application
][app_file] record is created in the database. When a user wants to sign in to your app, your app asks for a unique login URL to redirect the user to. The user goes there, enters their credentials, chooses the characters to grant access to, then clicks the login button. Core then redirects the user back to your app with a special 'token' argument in the URL. Your app can then use that token to access the user's information in Core. When the user clicked the login button (just before being redirected back to your app), Core looked up the Application
and created an [ApplicationGrant
][app_file] record. This grant stores what permissions a user has granted to your app, and are listed in the "Authorized" tab in the applications section of the Core interface.
[app_file]: https://github.com/bravecollective/core/blob/develop/brave/core/application/model.py
All of the messages back and forth between your app and the server are signed with the originator's private key, and verified with the appropriate public key. If you're encountering errors with an external Core instance, I highly recommend setitng a local instance up and turning the logging options up to figure out where the problem is occuring.
##Using the API
###Prep work First you need to generate an ECDSA keypair. You can either do it in Python using the ecdsa package or with the OpenSSL shell utilities. How to generate keypairs. First you need to have an application registered in Core. In the Core interface, click "Applications" in the sidebar, then go to the "Manage" tab. Then you can click the "Register Application" button. Fill in the fields under the "General" tab, and then under the "ECDSA Key" tab put the public (aka verifying) key in hex format in the textbox. The help text lies and it doesn't accept PEM encoded keys. After that you can click the "Save" button.
Now you need to get your application's identifier and the server public key. In the list of your applications (under the "Management" tab) click on your newly created application. Save the application id (short hex string) and the server public key (pick the format that's most convenient for you) somewhere.
###Writing the app