If you have built a quick test application on the Kloudless platform, chances are that you did so using default OAuth keys Kloudless provides to facilitate testing the API. If you have begun building your Kloudless integration, it is a great time to switch over to an OAuth flow that utilizes your own OAuth keys. This provides several benefits; it allows you to manage your own tokens, you get a better branding experience, and finally you won’t be sharing rate limits/quotas the Kloudless default keys are subject to. So let’s dive in!
In this example, we’ll walk through moving an existing Google Drive app from Default Kloudless keys to keys supplied by Google. To start off, navigate to the OAuth Credentials page in the developer portal for your app. You can find this page under Security -> Credentials in the developer portal. Be sure to select the correct app from the dropdown menu in the top left corner of the page. You should see a list of cloud storage services that looks something like this:
In our case, we are looking for the listing for Google Drive. When you find that entry, you will see that Google Drive is by default set to the Default Kloudless keys. If you have existing accounts connected to the Default key, you will see a message denoting the number of accounts using that key, and an option to delete these accounts bordered in red, with some additional information.
In our case, we do not need these accounts to continue to have access, and would like to have them re-authenticate through our app in the future. In this case I will check the box to have the existing accounts deleted. Please note, this deletion does not affect the contents of your account or delete the account; but they do remove access to the account the keys are associated with.
Once you click ‘Save’, the first thing you’ll see is several new fields with instructions and helpful information specific to OAuth tokens and Google.
Keep this browser tab open, we’ll be coming back to it in a bit. We’re now ready to head over to the Google Developers Console! If you haven’t yet, create a new Google project. This is where you’ll manage apps and services that request access to your users’ Google accounts, and generate a Client ID/Consumer Key and our Client Secret/Consumer Secret. Once that is done, there are a few steps to follow to get the information from the Google project. It should look something like the image below once you have created the project, with your project name in place of ‘kloudless test auth’.
Our next step is to create the credentials needed for the Kloudless app. Click on the ‘Credentials’ tab to look at our options for creating credentials. In this case, we’re creating an OAuth Client ID, so select that option and then select the correct application type. In this case, I selected ‘Web application’. All right! We now have a Client ID/Consumer Key and our Client Secret/Consumer Secret.
We’ve got something else to edit in the Google Developers Console; the callback URL or Redirect URI. Please refer back to the Kloudless Credentials page and grab the link supplied there. Copy and paste that into the field under ‘authorized redirect URIs’, and click save.
Please keep in mind that the Client secret is just that - a SECRET. Be mindful of where you save it, and do not leave it exposed in your documentation. Head back to the Kloudless Credentials page. Enter the Client ID and Client secret into their respective fields, and save the app.
That’s it! You have successfully moved your app from using the default Kloudless OAuth keys to your own OAuth keys.