コード例 #1
0
 public void DynamicScopeValidation(Enums.AuthScopes requiredScope, string accessToken = null)
 {
     if (!Validators.SkipDynamicScopeValidation && accessToken == null)
     {
         if (!Scopes.Contains(requiredScope) || (requiredScope == Enums.AuthScopes.Any && Scopes.Count == 0))
         {
             throw new InvalidCredentialException($"The current access token ({Scopes.ToString()}) does not support this call. Missing required scope: {requiredScope.ToString().ToLower()}. You can skip this check by using: TwitchLib.TwitchAPI.Settings.Validators.SkipDynamicScopeValidation = true . You can also generate a new token with this scope here: https://twitchtokengenerator.com");
         }
     }
 }
コード例 #2
0
 public void ValidateScope(Enums.AuthScopes requiredScope, string accessToken = null)
 {
     if (accessToken != null)
     {
         return;
     }
     if (Scopes.Contains(requiredScope))
     {
         throw new Exceptions.API.InvalidCredentialException($"The call you attempted was blocked because you are missing required scope: {requiredScope.ToString().ToLower()}. You can ignore this protection by using TwitchLib.TwitchAPI.Settings.Validators.SkipDynamicScopeValidation = false . You can also generate a new token with the required scope here: https://twitchtokengenerator.com");
     }
 }
コード例 #3
0
        public static string AuthScopesToString(Enums.AuthScopes scope)
        {
            switch (scope)
            {
            case Enums.AuthScopes.Channel_Check_Subscription:
                return("channel_check_subscription");

            case Enums.AuthScopes.Channel_Commercial:
                return("channel_commercial");

            case Enums.AuthScopes.Channel_Editor:
                return("channel_editor");

            case Enums.AuthScopes.Channel_Feed_Edit:
                return("channel_feed_edit");

            case Enums.AuthScopes.Channel_Feed_Read:
                return("channel_feed_read");

            case Enums.AuthScopes.Channel_Read:
                return("channel_read");

            case Enums.AuthScopes.Channel_Stream:
                return("channel_stream");

            case Enums.AuthScopes.Channel_Subscriptions:
                return("channel_subscriptions");

            case Enums.AuthScopes.Chat_Login:
                return("chat_login");

            case Enums.AuthScopes.Collections_Edit:
                return("collections_edit");

            case Enums.AuthScopes.Communities_Edit:
                return("communities_edit");

            case Enums.AuthScopes.Communities_Moderate:
                return("communities_moderate");

            case Enums.AuthScopes.User_Blocks_Edit:
                return("user_blocks_edit");

            case Enums.AuthScopes.User_Blocks_Read:
                return("user_blocks_read");

            case Enums.AuthScopes.User_Follows_Edit:
                return("user_follows_edit");

            case Enums.AuthScopes.User_Read:
                return("user_read");

            case Enums.AuthScopes.User_Subscriptions:
                return("user_subscriptions");

            case Enums.AuthScopes.Viewing_Activity_Read:
                return("viewing_activity_read");

            case Enums.AuthScopes.OpenId:
                return("openid");

            case Enums.AuthScopes.Helix_User_Edit:
                return("user:edit");

            case Enums.AuthScopes.Helix_User_Read_Email:
                return("user:read:email");

            default:
                return("");
            }
        }