-
首页
-
C4D R23.110 C++ SDK
NetworkOAuthSessionInterface Class Reference
#include <network_oauth.h>
详细描述
OAuth helps to connect to services using this protocol (
http://en.wikipedia.org/wiki/OAuth
) OAuth is used by a lot of APIs to deliver web based content (e.g. dropbox, google, twitter...) Supported are OAuth1 and OAuth2. Here is an prototype how to use the class functions.
公共成员函数
|
MAXON_METHOD
Result
<
String
>
|
InitV1Session
(const
Url
&service, const
String
&account, const
CString
&appKey, const
CString
&appSecret,
OAUTHSIGNATUREMETHOD
signatureMethod,
OAUTHHTTPMETHOD
httpMethod,
Bool
forceReapprovement, const
Delegate
<
Result
< void >(const NetworkOAuthSessionRef &session, const
Url
&url)> &askForApproval, const
Delegate
<
Result
<
String
>(const NetworkOAuthSessionRef &session)> &verifyAccountName)
|
MAXON_METHOD
Result
<
String
>
|
InitV2Session
(const
Url
&authUrl, const
Url
&tokenUrl, const
Url
&redirectUrl, const
String
&account, const
CString
&appKey, const
CString
&appSecret, const
CString
&scope,
Bool
forceReapprovement,
Bool
allowRedirectServer, const UrlRedirectRef &redirectRef, const
Delegate
<
Result
< void >(const NetworkOAuthSessionRef &session, const
Url
&url)> &askForApproval, const
Delegate
<
Result
<
String
>(const NetworkOAuthSessionRef &session, const DataDictionary &response)> &verifyAccountName)
|
MAXON_METHOD
Result
<
String
>
|
InitV2SessionWithResourceOwnerPasswordGrant
(const
Url
&tokenUrl, const
String
&userName, const
String
&password, const
String
&account, const
CString
&appKey, const
CString
&appSecret, const
CString
&scope, const
Delegate
<
Result
<
String
>(const NetworkOAuthSessionRef &session, const DataDictionary &response)> &verifyAccountName)
|
MAXON_METHOD
Result
<
String
>
|
InitV2SessionWithRefreshOrAccessToken
(const
Url
&tokenUrl, const
CString
&refreshToken, const
CString
&accessToken, const
CString
&appKey, const
CString
&appSecret, const
CString
&scope, const
Delegate
<
Result
<
String
>(const NetworkOAuthSessionRef &session, const DataDictionary &response)> &verifyAccountName)
|
MAXON_METHOD
Result
<
Url
>
|
SignUrl
(const
Url
&url,
OAUTHHTTPMETHOD
httpMethod) const
|
MAXON_METHOD
Result
<
BaseArray
< DataDictionary > >
|
ReadJson
(const
Url
&url,
OAUTHHTTPMETHOD
httpMethod, const StringDecodingRef &stringDecoding) const
|
MAXON_METHOD
Result
<
BaseArray
< DataDictionary > >
|
ReadJWT
(const
Url
&url,
OAUTHHTTPMETHOD
httpMethod, const StringDecodingRef &stringDecoding, const
Block
< const
Char
> &publicKey,
BaseArray
<
Char
> *originalToken) const
|
MAXON_METHOD
Int
|
GetAuthVersion
() const
|
MAXON_METHOD
String
|
GetAccount
() const
|
MAXON_METHOD
CString
|
GetAccessToken
() const
|
MAXON_METHOD
CString
|
GetRefreshToken
() const
|
MAXON_METHOD
Result
<
Url
>
|
GetOAuthTokenUrl
(const
String
&account) const
|
成员函数文档编制
◆
MAXON_INTERFACE_NONVIRTUAL()
◆
Alloc()
◆
InitV1Session()
Starts a OAuth1 session. The first time (or if forceReapprovement is true) the user will be asked for credentials to access the service.
-
参数
-
[in]
|
service
|
Service provider to connect with (e.g. "https://api.dropbox.com/1/oauth"). This id will be used to store the access keys together with the account.
|
[in]
|
account
|
Account to connect with. Depending on the service provider this can be the mail address or name. This value is used to store the private access tokens. Leave blank to create a new login. If the
String
was empty check the return value for the newly created account name.
|
[in]
|
appKey
|
应用程序
Key from the provider.
|
[in]
|
appSecret
|
应用程序
Secret from the provider.
|
[in]
|
signatureMethod
|
Signature method to sign with. OAUTHHTTPMETHOD::PLAINTEXT should only be used for non ssl connections. This method will be used for all url signings.
|
[in]
|
httpMethod
|
Http method to sign with.
|
[in]
|
forceReapprovement
|
Set to true to delete the old cached tokens and ask the user for new approval on the web side of the provide.
|
[in]
|
askForApproval
|
Optional callback to ask the user for approval of the a new session token. Usually a web browser opens the url where the user needs to click "Accept". Set to nullptr if you want the standard behavior "url.IoShowInOS(IOSHOWINOSFLAGS::OPEN_IN_EXPLORER)". This callback is only triggered if there is no valid session token found.
|
[in]
|
verifyAccountName
|
Callback to verify the stored token and retrieve the account name. This callback is triggered on the first connect.
|
-
返回
-
Returns the account name delivered by the provider.
◆
InitV2Session()
MAXON_METHOD
Result
<
String
> InitV2Session
|
(
|
const
Url
&
|
authUrl
,
|
|
|
const
Url
&
|
tokenUrl
,
|
|
|
const
Url
&
|
redirectUrl
,
|
|
|
const
String
&
|
account
,
|
|
|
const
CString
&
|
appKey
,
|
|
|
const
CString
&
|
appSecret
,
|
|
|
const
CString
&
|
scope
,
|
|
|
Bool
|
forceReapprovement
,
|
|
|
Bool
|
allowRedirectServer
,
|
|
|
const UrlRedirectRef &
|
redirectRef
,
|
|
|
const
Delegate
<
Result
< void >(const NetworkOAuthSessionRef &session, const
Url
&url)> &
|
askForApproval
,
|
|
|
const
Delegate
<
Result
<
String
>(const NetworkOAuthSessionRef &session, const DataDictionary &response)> &
|
verifyAccountName
|
|
)
|
|
|
Starts a OAuth2 session. The first time (or if forceReapprovement is true) the user will be asked for credentials to access the service.
-
参数
-
[in]
|
authUrl
|
Https://accounts.google.com/o/oauth2/auth.
|
[in]
|
tokenUrl
|
Https://accounts.google.com/o/oauth2/token.
|
[in]
|
account
|
Account to connect with. Depending on the service provider this can be the mail address or name. This value is used to store the private access tokens. Leave blank to create a new login. If the
String
was empty check the return value for the newly created account name.
|
[in]
|
appKey
|
应用程序
Key from the provider.
|
[in]
|
appSecret
|
应用程序
Secret from the provider.
|
[in]
|
forceReapprovement
|
Set to true to delete the old cached tokens and ask the user for new approval.
|
[in]
|
allowRedirectServer
|
True if the application should run a local server to catch the redirect. If false the server-less method can be used to catch the browser redirects directly.
|
[in]
|
redirectRef
|
Optional parameter server-less authentication (see
UrlRedirectInterface
).
|
[in]
|
askForApproval
|
Optional callback to ask the user for approval of the a new session token. Usually a web browser opens the url where the user needs to click "Accept". Set to nullptr if you want the standard behavior "url.IoShowInOS(IOSHOWINOSFLAGS::OPEN_IN_EXPLORER)". This callback is only triggered if there is no valid session token found.
|
[in]
|
verifyAccountName
|
Callback to verify the stored token and retrieve the account name. This callback is triggered on the first connect.
|
-
返回
-
Returns the account name delivered by the provider.
◆
InitV2SessionWithResourceOwnerPasswordGrant()
Starts a OAuth2 session with the "Resource Owner Password Grant" method. This is less secure because the user name and password needs to be entered in the code and there is no redirect url where the server can send the result back to the verified source.
-
参数
-
[in]
|
tokenUrl
|
Url
to the toke url. this generates a http post to get the oauth access token.
|
[in]
|
userName
|
User
name to login with.
|
[in]
|
password
|
Password for the given username.
|
[in]
|
account
|
Account to connect with. Depending on the service provider this can be the mail address or name. This value is used to store the private access tokens. Leave blank to create a new login. If the
String
was empty check the return value for the newly created account name.
|
[in]
|
appKey
|
应用程序
Key from the provider.
|
[in]
|
appSecret
|
应用程序
Secret from the provider.
|
[in]
|
verifyAccountName
|
Callback to verify the stored token and retrieve the account name. This callback is triggered on the first connect.
|
-
返回
-
Returns the account name delivered by the provider.
◆
InitV2SessionWithRefreshOrAccessToken()
Starts a OAuth2 session with the "Refresh Token Grant" method. First the access token will be tried, if it's expired the refresh token will be used to generate a new access token.
-
参数
-
[in]
|
tokenUrl
|
Url
to the toke url. this generates a http post to get the oauth access token.
|
[in]
|
refreshToken
|
OAuth2.0 refresh token from the last session.
|
[in]
|
accessToken
|
OAuth2.0 access token from the last session.
|
[in]
|
appKey
|
应用程序
Key from the provider.
|
[in]
|
appSecret
|
应用程序
Secret from the provider.
|
[in]
|
verifyAccountName
|
Callback to verify the stored token and retrieve the account name. This callback is triggered on the first connect.
|
-
返回
-
Returns the account name delivered by the provider.
◆
SignUrl()
Signs a
Url
with the authentication tokens using the selected methods.
-
参数
-
[in]
|
url
|
Url
to be signed.
|
[in]
|
httpMethod
|
Http method to sign with.
|
◆
ReadJson()
Signs and reads a given url directly into a json dictionary.
-
参数
-
[in]
|
url
|
Url
to be signed and read.
|
[in]
|
httpMethod
|
Http method to load the file.
|
◆
ReadJWT()
Signs and reads a given url directly into a json dictionary.
-
参数
-
[in]
|
url
|
Url
to be signed and read.
|
[in]
|
httpMethod
|
Http method to load the file.
|
◆
GetAuthVersion()
Returns the auth version used by this session. The protocol version can be 1 or 2.
◆
GetAccount()
Returns the user account id connected to this session.
◆
GetAccessToken()
GetOAuthToken returns the OAuth token to access the resource.
-
返回
-
Token string on success.
◆
GetRefreshToken()
GetOAuthToken returns the OAuth token to access the resource.
-
返回
-
Token string on success.
◆
GetOAuthTokenUrl()
Returns the url where the login token is stored.
-
返回
-
OK on success.