You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added addition instruction and code examples for configuring for Content-Type:application/x-www-form-urlencoded, using a UIWebView and calling handleRedirectURL:
Copy file name to clipboardExpand all lines: README.md
+31Lines changed: 31 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -80,6 +80,19 @@ The best place to configure your client is `+[UIApplicationDelegate initialize]`
80
80
81
81
Take a look at the [Wiki](https://github.com/nxtbgthng/OAuth2Client/wiki) for some examples.
82
82
83
+
Unless otherwise specficied, the token request will be called with a HTTP Header 'Content-Type' set to 'multipart/form-data'. If you wish that header to be set to 'application/x-www-form-urlencoded', the custom header fields must be modified.
Consult the documentation of the OAuth2 provider to determine acceptable Content-Type header values.
93
+
94
+
95
+
83
96
### Requesting Access to a Service
84
97
85
98
Once you have configured your client you are ready to request access to one of those services. The NXOAuth2AccountStore provides three different methods for this:
@@ -106,6 +119,24 @@ Once you have configured your client you are ready to request access to one of t
106
119
}];
107
120
</pre>
108
121
Using an authorization URL handler gives you the ability to open the URL in an own web view or do some fancy stuff for authentication. Therefore you pass a block to the NXOAuth2AccountStore while requesting access.
122
+
123
+
One method for receiving a code and exchanging it for an auth token requires the following:
124
+
125
+
1) Load the preparedURL into an existing UIWebView as part of the block code above. Be certain to set the delegate for the UIWebView.
2) In the `webViewDidFinishLoad:` delegate method, you will need to parse the URL for your callback URL. If there is a match, pass that URL to `handleRedirectURL:`
132
+
133
+
<pre>
134
+
if ([webView.request.URL.absoluteString rangeOfString:kOAuth2RedirectURL options:NSCaseInsensitiveSearch].location != NSNotFound) {
This is a very basic example. In the above, it is assumed that the `code` being returned from the OAuth2 provider is in the query parameter of the webView.request.URL (i.e. `http://myredirecturl.com?code=<verylongcodestring>`). This is not always the case and you may have to look elsewhere for the code (e.g. in the page content, web page title). You must prepare a URL in the format described above to pass to `handleRedirectURL:`.
0 commit comments