bdbergeron / BDBOAuth1Manager

OAuth 1.0a library for AFNetworking 2.x
MIT License
100 stars 35 forks source link

Yelp provides token #28

Closed pjebs closed 9 years ago

pjebs commented 9 years ago

When you create a Yelp Developer Account they provide you with ready-made/fixed: Consumer Key, Consumer Secret, Token, Token Secret.

I was wondering if it was possible to use your library without having to call: fetchAccessTokenWithPath:

(since you already have the token)

bdbergeron commented 9 years ago

This should be quite easy to do. Take a look at BDBOAuth1RequestSerializer.h; you'll notice that the request serializer uses an instance of BDBOAuth1Credential for the access token. You should simply be able to instantiate a new access token using the following method and then call saveAccessToken: on the request serializer, passing in the access token.

BDBOAuth1Credential *accessToken = [BDBOAuth1Credential credentialWithToken:token secret:secret expiration:expiration];
[self.networkManager.requestSerializer saveAccessToken:accessToken];

In this snippet, self.networkManager is your instance of BDBOAuth1RequestOperationManager or BDBOAuth1SessionManager, depending on what you're using. You don't need to do anything special when instantiating those.