---
# System prepended metadata

title: 'Twitter: Protecting Your Keys - Feature Guide'

---

# Twitter: Protecting Your Keys - Feature Guide

## 1. Overview

Protecting your API keys and secrets keeps your account from getting compromised.😰 Depending on the API you are using, it can lead to unexpected charges on your account, the public having access to your data, or losing access to the API. Thus, we are going to show you 1 of the many ways to secure it!🤐

## 2. Creating a Property List
* Right click the twitter folder then go to `New File... -> Property List` name it `Keys`.
* Press the **+** sign next to Dictionary and add your Key and Secret. Name them `consumer_Key` and `consumer_Secret` respectively. Set their values to the values you got off of the API.
![](https://i.imgur.com/BeEXZFA.gif)

## 3. Accessing the Values on the Property List
* Add the following to your `APIManager.m` file inside your `init` method.

	```objc
	// TODO: Code to get the consumer key and secret from keys.plist

	NSString *path = [[NSBundle mainBundle] pathForResource: @"Keys" ofType: @"plist"];
	NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile: path];
	NSString *secret = [dict objectForKey: @"consumer_Secret"];
	NSString *key= [dict objectForKey: @"consumer_Key"];
	```

## 4. Gitignore the Property List
* Go to `Xcode -> Prefences -> Source Countrol`. Then click on the `Git` tab and press the **+** to add your `Keys.plist` file. 
![](https://i.imgur.com/3l8A30b.gif)
     - **Note:** On any project, from here on out, xcode automatically gitignores any file named `Keys.plist`! 😌