# User-api-key returning error on generating new key

**URL:** https://meta.discourse.org/t/user-api-key-returning-error-on-generating-new-key/117269
**Category:** Development
**Created:** [5월 9, 2019, 12:57오후 UTC](https://meta.discourse.org/t/user-api-key-returning-error-on-generating-new-key/117269 "2019-05-09T12:57:04Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![kristoferlund](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kristoferlund/32/140560_2.png) [@kristoferlund](https://meta.discourse.org/u/kristoferlund)
#### Post date: [5월 9, 2019, 12:57오후 UTC](https://meta.discourse.org/t/user-api-key-returning-error-on-generating-new-key/117269/1 "2019-05-09T12:57:04Z")

</div>

Hi, I’m developing an app that wants to access Discourse through the user api. Everything works fine up until the point where Discourse should redirect with the newly generated user api key.

Error message in the API logs: `OpenSSL::PKey::RSAError (data too large for key size)`

This is the request leading up to the error:

```plaintext
https://myforum.se/user-api-key/new?auth_redirect=https%3A%2F%2F1aff6e79.ngrok.io%2Fauth_redirect&application_name=Discourse%20Lanes&client_id=discourse-lanes&scopes=read%2Cwrite&public_key=-----BEGIN%20PUBLIC%20KEY-----%0AMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAIaAlveu4rD1xwFOMfI0QJzLjBgomdAt%0Adq0DFydzepQqwVmZxFjYzNTG8VO0yLQbr4wxXQLoAgKnf16Wm2Qk0CUCAwEAAQ%3D%3D%0A-----END%20PUBLIC%20KEY-----&nonce=876876

```

Should I pass another type of public key to `user-api-key/new` or how could I resolve this?

---

<div class="post-metadata">

### Author: ![kristoferlund](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kristoferlund/32/140560_2.png) [@kristoferlund](https://meta.discourse.org/u/kristoferlund)
#### Post date: [5월 9, 2019, 1:22오후 UTC](https://meta.discourse.org/t/user-api-key-returning-error-on-generating-new-key/117269/2 "2019-05-09T13:22:27Z")

</div>

Solved: used a 1024 bit key instead of 512.
