TwitchLib 3.5.3
Loading...
Searching...
No Matches
TwitchLib.Api.Auth.Auth Class Reference

These endpoints fall outside of v5 and Helix, and relate to Authorization More...

Inheritance diagram for TwitchLib.Api.Auth.Auth:
TwitchLib.Api.Core.ApiBase

Public Member Functions

 Auth (IApiSettings settings, IRateLimiter rateLimiter, IHttpCallHandler http)
 
Task< RefreshResponseRefreshAuthTokenAsync (string refreshToken, string clientSecret, string clientId=null)
 
string GetAuthorizationCodeUrl (string redirectUri, IEnumerable< AuthScopes > scopes, bool forceVerify=false, string state=null, string clientId=null)
 Generates an authorization code URL. Please see OAuth authorization code flow https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/#oauth-authorization-code-flow. More...
 
Task< AuthCodeResponseGetAccessTokenFromCodeAsync (string code, string clientSecret, string redirectUri, string clientId=null)
 
async Task< ValidateAccessTokenResponseValidateAccessTokenAsync (string accessToken=null)
 Checks the validation of the Settings.AccessToken or passed in AccessToken. If invalid, a null response is returned More...
 
- Public Member Functions inherited from TwitchLib.Api.Core.ApiBase
 ApiBase (IApiSettings settings, IRateLimiter rateLimiter, IHttpCallHandler http)
 
async ValueTask< string > GetAccessTokenAsync (string accessToken=null)
 

Additional Inherited Members

- Protected Member Functions inherited from TwitchLib.Api.Core.ApiBase
async Task< string > TwitchGetAsync (string resource, ApiVersion api, List< KeyValuePair< string, string > > getParams=null, string accessToken=null, string clientId=null, string customBase=null)
 
async Task< T > TwitchGetGenericAsync< T > (string resource, ApiVersion api, List< KeyValuePair< string, string > > getParams=null, string accessToken=null, string clientId=null, string customBase=null)
 
async Task< T > TwitchPatchGenericAsync< T > (string resource, ApiVersion api, string payload, List< KeyValuePair< string, string > > getParams=null, string accessToken=null, string clientId=null, string customBase=null)
 
async Task< string > TwitchPatchAsync (string resource, ApiVersion api, string payload, List< KeyValuePair< string, string > > getParams=null, string accessToken=null, string clientId=null, string customBase=null)
 
async Task< KeyValuePair< int, string > > TwitchDeleteAsync (string resource, ApiVersion api, List< KeyValuePair< string, string > > getParams=null, string accessToken=null, string clientId=null, string customBase=null)
 
async Task< T > TwitchPostGenericAsync< T > (string resource, ApiVersion api, string payload, List< KeyValuePair< string, string > > getParams=null, string accessToken=null, string clientId=null, string customBase=null)
 
async Task< T > TwitchPostGenericModelAsync< T > (string resource, ApiVersion api, RequestModel model, string accessToken=null, string clientId=null, string customBase=null)
 
async Task< T > TwitchDeleteGenericAsync< T > (string resource, ApiVersion api, List< KeyValuePair< string, string > > getParams=null, string accessToken=null, string clientId=null, string customBase=null)
 
async Task< T > TwitchPutGenericAsync< T > (string resource, ApiVersion api, string payload=null, List< KeyValuePair< string, string > > getParams=null, string accessToken=null, string clientId=null, string customBase=null)
 
async Task< string > TwitchPutAsync (string resource, ApiVersion api, string payload, List< KeyValuePair< string, string > > getParams=null, string accessToken=null, string clientId=null, string customBase=null)
 
async Task< KeyValuePair< int, string > > TwitchPostAsync (string resource, ApiVersion api, string payload, List< KeyValuePair< string, string > > getParams=null, string accessToken=null, string clientId=null, string customBase=null)
 
Task PutBytesAsync (string url, byte[] payload)
 
async Task< T > GetGenericAsync< T > (string url, List< KeyValuePair< string, string > > getParams=null, string accessToken=null, ApiVersion api=ApiVersion.Helix, string clientId=null)
 
- Protected Attributes inherited from TwitchLib.Api.Core.ApiBase
readonly IApiSettings Settings
 

Detailed Description

These endpoints fall outside of v5 and Helix, and relate to Authorization

Constructor & Destructor Documentation

◆ Auth()

TwitchLib.Api.Auth.Auth.Auth ( IApiSettings  settings,
IRateLimiter  rateLimiter,
IHttpCallHandler  http 
)

Member Function Documentation

◆ GetAccessTokenFromCodeAsync()

Task< AuthCodeResponse > TwitchLib.Api.Auth.Auth.GetAccessTokenFromCodeAsync ( string  code,
string  clientSecret,
string  redirectUri,
string  clientId = null 
)

[ASYNC] Uses an authorization code to generate an access token

ATTENTION: Client Secret required. Never expose it to consumers!

Throws a BadRequest Exception if the request fails due to a bad code token

Parameters
codeThe OAuth 2.0 authorization code is a 30-character, randomly generated string. Used in the request made to the token endpoint in exchange for an access token.
clientSecretRequired for API access.
redirectUriThe URI the user was redirected to. This URI must be registered with your twitch app or extension.
clientIdThe client ID of your app or extension.
Returns
A RefreshResponse object that holds your new auth and refresh token and the list of scopes for that token

◆ GetAuthorizationCodeUrl()

string TwitchLib.Api.Auth.Auth.GetAuthorizationCodeUrl ( string  redirectUri,
IEnumerable< AuthScopes scopes,
bool  forceVerify = false,
string  state = null,
string  clientId = null 
)

Generates an authorization code URL. Please see OAuth authorization code flow https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/#oauth-authorization-code-flow.

Parameters
redirectUriYour registered redirect URI. This must exactly match the redirect URI registered in the prior, Registration step.
scopesSpace-separated list of scopes.
forceVerifySpecifies whether the user should be re-prompted for authorization. If this is true, the user always is prompted to confirm authorization. This is useful to allow your users to switch Twitch accounts, since there is no way to log users out of the API. Default: false (a given user sees the authorization page for a given set of scopes only the first time through the sequence).
stateYour unique token, generated by your application. This is an OAuth 2.0 opaque value, used to avoid CSRF attacks. This value is echoed back in the response. We strongly recommend you use this.
clientIdYour client ID.
Returns
A URL encoded string that can be used to generate a user authorization code.
Exceptions
BadParameterExceptionThrown when any of the required parameters are not valid.

◆ RefreshAuthTokenAsync()

Task< RefreshResponse > TwitchLib.Api.Auth.Auth.RefreshAuthTokenAsync ( string  refreshToken,
string  clientSecret,
string  clientId = null 
)

[ASYNC] Refreshes an expired auth token

ATTENTION: Client Secret required. Never expose it to consumers!

Throws a BadRequest Exception if the request fails due to a bad refresh token

Returns
A RefreshResponse object that holds your new auth and refresh token and the list of scopes for that token

◆ ValidateAccessTokenAsync()

async Task< ValidateAccessTokenResponse > TwitchLib.Api.Auth.Auth.ValidateAccessTokenAsync ( string  accessToken = null)

Checks the validation of the Settings.AccessToken or passed in AccessToken. If invalid, a null response is returned

Parameters
accessTokenOptional access token to check validation on
Returns
ValidateAccessTokenResponse

The documentation for this class was generated from the following file: