hank
2017-06-14 a0a84333e64f1e94ae9d0f69545037c60e781842
commit | author | age
a0a843 1 //
H 2 //  TWTRCoreOAuthSigning.h
3 //
4 //  Copyright (c) 2015 Twitter. All rights reserved.
5 //
6
7 #import <Foundation/Foundation.h>
8
9 NS_ASSUME_NONNULL_BEGIN
10
11 FOUNDATION_EXPORT NSString *const TWTROAuthEchoRequestURLStringKey;
12 FOUNDATION_EXPORT NSString *const TWTROAuthEchoAuthorizationHeaderKey;
13
14 @protocol TWTRCoreOAuthSigning <NSObject>
15
16 /**
17  *  @name OAuth Echo
18  */
19
20 /**
21  *  OAuth Echo is a means to securely delegate OAuth authorization to a third party while interacting with an API.
22  *  For example, you may wish to verify a user's credentials from your app's server (the third party) rather than your app.
23  *  This method provides you with the OAuth signature to add to the third party's request to `URLString`, as well as the formed
24  *  URL with the query string to send that request to.
25  *  This is equivalent to calling `-URLRequestWithMethod:URL:parameters:error:` and getting the URL and the `Authorization` HTTP header out of the request.
26  *
27  *  @param method       Request method, GET, POST, PUT, DELETE, etc.
28  *  @param URLString    The full URL of the Twitter endpoint you plan to send a request to. E.g. https://api.twitter.com/1.1/account/verify_credentials.json
29  *  @param parameters   Request parameters.
30  *  @param error        Error in the `TWTRErrorDomain` domain. The code will be `TWTRErrorCodeInvalidURL` if the `URLString`'s host is not api.twitter.com
31  *
32  *  @return `nil` if there's an error or a missing required parameter, or a dictionary with the fully formed request URL under `TWTROAuthEchoRequestURLStringKey` (`NSString`), and the `Authorization` header in `TWTROAuthEchoAuthorizationHeaderKey` (`NSString`), to be used to sign the request.
33  *
34  *  @see More information about OAuth Echo: https://dev.twitter.com/oauth/echo
35  */
36 - (NSDictionary *)OAuthEchoHeadersForRequestMethod:(NSString *)method URLString:(NSString *)URLString parameters:(nullable NSDictionary *)parameters error:(NSError **)error;
37
38 /**
39  *  This method provides you with the OAuth signature, as well as the formed URL with the query string, to send a request to `verify_credentials`.
40  *
41  *  @return A dictionary with the fully formed Request URL under `TWTROAuthEchoRequestURLStringKey` (`NSString`), and the `Authorization` header in `TWTROAuthEchoAuthorizationHeaderKey` (`NSString`), to be used to sign the request.
42  *
43  *  @see More information about OAuth Echo: https://dev.twitter.com/oauth/echo
44  *  @see More information about Verify Credentials: https://dev.twitter.com/rest/reference/get/account/verify_credentials
45  */
46 - (NSDictionary *)OAuthEchoHeadersToVerifyCredentials;
47
48 @end
49
50 NS_ASSUME_NONNULL_END