Search code examples
iosoauthuiwebviewtumblr

iOS Tumblr Integration using oauth


Trying to understand how this all works. New to oauth and api integrations. Not looking for a better way. Looking to understand and expand on what this is doing.

I followed this tutorial and have it working through part 3.

I kind of understand, but having a hard time connecting the code to the Tumblr API documentation.

The tutorial leaves off with having the user's Access Token.

How do I use the Access Token to get the users info with api.tumblr.com/v2/user/info in xcode?

With this information I might be able to put together an understanding in my head.

Code example would be much appreciated!


Solution

  • @Ir100, use the same acess_token and secret_key you generated via OAuth Library and just change your request url(API) because every time you have to send other parameter for API call.

    _consumer = [[OAConsumer alloc] initWithKey: _consumerKey secret: _secretKey];
    
    OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL: url consumer: _consumer token:token realm:nil signatureProvider: nil] ;
    if (!request) return;
    
    if (self.pin.length)
        token.verifier = _pin;
    
    [request setHTTPMethod: @"POST"];
    
    if (_api)
    [request setHTTPMethod: @"GET"];
    
    NSMutableArray *params =  [[NSMutableArray alloc] initWithArray:request.oa_parameters];
    request.oa_parameters = params;
    
    OADataFetcher               *fetcher = [[OADataFetcher alloc] init] ;
    [fetcher fetchDataWithRequest: request delegate: self didFinishSelector: success didFailSelector: fail];