Advertisement
GamerRO

Untitled

Aug 20th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. using System;
  2. using System.Net;
  3. using System.Net.Security;
  4. using System.Security.Cryptography.X509Certificates;
  5. using UnityEngine;
  6. using TwitchLib;
  7. using TwitchLib.Events.Client;
  8. using TwitchLib.Models.Client;
  9.  
  10. public class GamerTwitchLib : MonoBehaviour {
  11.  
  12. private void Start()
  13. {
  14. ServicePointManager.ServerCertificateValidationCallback = CertificateValidationMonoFix;
  15.  
  16. string userName = "GamerBOT28";
  17. string clientID = "aav9foqxbflb676m8rkjqt7trlj5gk";
  18. string accessToken = "obl3i78b2mlvqc6brg50pnb3t7yh80";
  19. string channelToJoin = "GamerRO28";
  20.  
  21. ConnectionCredentials credentials = new ConnectionCredentials(userName, accessToken);
  22.  
  23. TwitchAPI.Settings.ClientId = clientID;
  24. TwitchAPI.Settings.AccessToken = accessToken;
  25.  
  26. TwitchClient client = new TwitchClient(credentials, channelToJoin);
  27.  
  28. client.OnJoinedChannel += ClientOnJoinedChannel;
  29.  
  30. client.Connect();
  31. }
  32.  
  33. private void ClientOnJoinedChannel(object sender, OnJoinedChannelArgs onJoinedChannelArgs)
  34. {
  35. Debug.Log($"User {onJoinedChannelArgs.Username} joined the channel!");
  36. }
  37.  
  38. public bool CertificateValidationMonoFix(System.Object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
  39. {
  40. bool isOk = true;
  41.  
  42. if (sslPolicyErrors == SslPolicyErrors.None)
  43. {
  44. return true;
  45. }
  46.  
  47. foreach (X509ChainStatus status in chain.ChainStatus)
  48. {
  49. if (status.Status == X509ChainStatusFlags.RevocationStatusUnknown)
  50. {
  51. continue;
  52. }
  53.  
  54. chain.ChainPolicy.RevocationFlag = X509RevocationFlag.EntireChain;
  55. chain.ChainPolicy.RevocationMode = X509RevocationMode.Online;
  56. chain.ChainPolicy.UrlRetrievalTimeout = new TimeSpan(0, 1, 0);
  57. chain.ChainPolicy.VerificationFlags = X509VerificationFlags.AllFlags;
  58.  
  59. bool chainIsValid = chain.Build((X509Certificate2)certificate);
  60.  
  61. if (!chainIsValid)
  62. {
  63. isOk = false;
  64. }
  65. }
  66.  
  67. return isOk;
  68. }
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement