Generating User API Keys with REST API
Umer_Mirza is trying to generate user API keys using the REST API, but is encountering an error “THIS PAGE IS PRIVATE OR DOES NOT EXISTS” when making a GET request. joffreyjaffeux provides an example of generating an API key using a different method, but djensen47 notes that this is not the same API that Umer_Mirza is asking about.
sam confirms that user API keys do exist and are consumed by the mobile app. joffreyjaffeux provides links to relevant code snippets, which djensen47 finds helpful. However, djensen47 is still unable to get the API working, and sajattack also encounters issues.
After some investigation, sajattack uncovers the required fields for generating a user API key, including scopes, client-id, nonce, auth_redirect, application_name, and public_key. sajattack also discovers that client-id is 32 random bytes and nonce is 16 random bytes.
sam notes that the redirect URL needs to go somewhere where the payload can be decrypted, and there is a site setting that lists where the redirect is allowed to go. david explains that user API keys behave differently from the API keys described at docs.discourse.org, and need to be sent as a request header instead of a GET parameter.
Key Takeaways:
- User API keys exist and are consumed by the mobile app
- The API is not fully documented, but relevant code snippets are available
- Required fields for generating a user API key include
scopes, client-id, nonce, auth_redirect, application_name, and public_key
- User API keys need to be sent as a request header instead of a GET parameter
- The redirect URL needs to go somewhere where the payload can be decrypted, and there is a site setting that controls this.