GenerateToken() public method

public GenerateToken ( GrantType grantType, IEnumerable scopes, string username = null, string code = null, string redirectUri = null, string password = null, string refreshToken = null ) : HipchatGenerateTokenResponse
grantType GrantType
scopes IEnumerable
username string
code string
redirectUri string
password string
refreshToken string
return HipchatGenerateTokenResponse
        //[Fact]
        public void GenerateAuthToken()
        {
            //insert your authId and auth Secret here
            const string authId = "";
            const string authSecret = "";

            var client = new HipchatClient();

            var token = client.GenerateToken(GrantType.ClientCredentials,
                new List<TokenScope> {TokenScope.SendNotification}, authId, authSecret);

            Assert.NotNull(token);
        }
Ejemplo n.º 2
0
        //[Fact]
        public void GenerateAuthTokenWithUsernameAndPassword()
        {
            //insert your username and password here
            const string username = "";
            const string password = "";

            var client = new HipchatClient("YourToken");

            var token = client.GenerateToken(GrantType.Password, Enumerable.Empty<TokenScope>(),
                username, password:password);

            Assert.NotNull(token);
        }
Ejemplo n.º 3
0
        public void GenerateTokenExample()
        {
            var client = new HipchatClient();

            var token = client.GenerateToken(GrantType.ClientCredentials,
                new List<TokenScope>
                {
                    TokenScope.SendNotification,
                },
                "", /*Auth Id*/
                "" /*Auth Secret*/);

            Assert.NotNull(token);
        }
        private void Write(object message, Exception exception, RoomColors color)
        {
            var sb = new StringBuilder();

            if (ApplicationName != null)
            {
                sb.Append("<b>Application: </b>" + ApplicationName).Append(NEW_LINE);
            }
            sb.Append(message).Append(NEW_LINE);

            while (exception != null)
            {
                sb.Append("Message: ").Append(exception.Message).Append(NEW_LINE)
                    .Append("Source: ").Append(exception.Source).Append(NEW_LINE)
                    .Append("Target site: ").Append(exception.TargetSite).Append(NEW_LINE)
                    .Append("Stack trace: ").Append(exception.StackTrace).Append(NEW_LINE);

                exception = exception.InnerException;
            }

            var hipchatClient = new HipchatClient(_hipchatAuthToken);

            if (_hipchatAuthSecret != null && _hipchatAuthSecret != null)
            {
                var token = hipchatClient.GenerateToken(GrantType.ClientCredentials,
                new List<TokenScope>
                {
                    TokenScope.SendNotification,
                },
                _hipchatAuthId,/*Auth Id*/
                _hipchatAuthSecret /*Auth Secret*/);

                HipchatApiConfig.AuthToken = token.Access_Token;
                hipchatClient.SendNotification(_roomName, sb.ToString(), color);
            }
            else
            {
                hipchatClient.SendNotification(_roomName, sb.ToString(), color);
            }
               
        }