How to authenticate iOS/iPhone users with remote web application and re-use authentication ticket in future requests to the same web application?

后端 未结 4 2021
无人及你
无人及你 2021-01-31 11:14

I am building an iOS application and I need to be able to make authenticated requests to a Rails 3 application for various bits of data. The Rails 3 application is using omniau

4条回答
  •  难免孤独
    2021-01-31 11:32

    1. Once the UIWebview has authenticated with said service, get it to load another URL (for example: through a javascript on the page which said service returns to after authentication).

    2. Capture this request using a UIWebViewDelegate object which implements the following protocol method:

      - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
      
    3. From here you have the NSURLRequest object. You can extract the headers of the request to NSDictionary which will contain the authentication cookie details, token, etc. using the following method of NSURLRequest

      - (NSDictionary *)allHTTPHeaderFields
      

提交回复
热议问题