GithubHelp home page GithubHelp logo

eyeem / asi-http-request-oauth Goto Github PK

View Code? Open in Web Editor NEW

This project forked from altertap/asi-http-request-oauth

0.0 4.0 0.0 100 KB

Adds OAuth signing to ASIHTTPRequest

License: MIT License

Objective-C 100.00%

asi-http-request-oauth's Introduction

This is my implementation of OAuth signing for ASIHTTPRequest. Unlike other implementations, this isn't a subclass of either ASIHTTPRequest or ASIFormDataRequest but a Category (mostly on the former). This allows it to be used with all methods, and other sub-classes you might make (such as my own NIHJSONRequest class at https://github.com/keybuk/nih-json-request).

Since it's a category, you should include this header instead of the usual one. Construct your ASIHTTPRequest as normal, and before you start, send the signRequestWithClientIdentifier:secret:tokenIdentifier:secret:usingMethod message to add the Authorization header.

  #import "ASIHTTPRequest+OAuth.h"

  NSURL *url = [NSURL URLwithString:@"http://example.com/test?hobbit=frodo&ring=of+power"];
  ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];

  [request signRequestWithClientIdentifier:clientIdentifier secret:clientSecret
                           tokenIdentifier:tokenIdentifier secret:tokenSecret
                               usingMethod:ASIOAuthHMAC_SHA1SignatureMethod[;
  [request start];

When working with forms, you should include ASIFormDataRequest+OAuth.h to have the body parameters included.

Two methods are left blank for overriding in sub-classes or categories of sub-classes. These are oauthPostBodyParameters and oauthAdditionalParametersForMethod: - both may return nil, or an array of dictionaries with "key" and "value" members. Parameters returned by the former are added to the base string only, parameters returned by the latter are instead added to the Authorization: OAuth header and only included in the signature if they begin "oauth_".

For examples see the ASIFormDataRequest+OAuth category or the NIHJSONRequest+OAuth category in my other repo.

asi-http-request-oauth's People

Contributors

bkook avatar keybuk avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.