AFNetworking/AFOAuth2Client — pull request #6 by conradev (2012-11-27 05:57:14+00:00)
Title: Overhaul client to better conform to OAuth2 spec

I made a slew of changes to the client, ones that I hope push it in the right direction.

## Changes Made

- I updated the library to use ARC.

- I removed `AFOAuthAccount`. I made this decision because an account abstraction *only* makes sense for the `password` grant type. The `password` grant type is the only grant type with any sort of account identifier (i.e. username) in the request or response. The response from the token endpoint only returns information about the token, and the best representation for this is a 'credential' object. Thus, all authentication success handlers are now given a `AFOAuthCredential` object. The removal of the account class also prompted me to rename `AFOauthAccountCredential` to `AFOAuthCredential`.

- I transformed the `client_id` and `client_secret` values into readonly properties on the client object. This removes the need to pass these values as arguments repeatedly, when there is no need to. They are fixed and unchanging values. This mimics the behavior in [AFOAuth1Client](https://github.com/AFNetworking/AFOAuth1Client/blob/master/AFOAuth1Client.h), where the `key` and `secret` properties were treated in much the same manner.

- I removed the check for token expiration in the success callback of the OAuth token requests. An expired credential would never be returned from a request to the token endpoint. In addition to this, the success callback also now checks for the `error` field and calls the `failure` callback if appropriate.

- I removed the `secret` property from the credential object, because it is intrinsic to the client, and not the credential. I added the `tokenType` property because it provides critical information on how the access token should be used.

- I added the header `Accept: application/json` to each OAuth request, because all responses should be formatted in JSON, according to the spec. For this reason, `AFJSONRequestOperation` is also registered as an HTTP operation class by default.

- Lastly, support for the `authorization_code` grant type was added.