コード例 #1
0
        /// <summary>
        /// Refresh an IAM token using a refresh token.
        /// </summary>
        /// <param name="callback">The success callback.</param>
        /// <param name="failCallback">The fail callback.</param>
        /// <returns></returns>
        public bool RefreshIamToken(Callback <IamTokenData> callback)
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            RESTConnector connector = new RESTConnector();

            connector.URL = _iamUrl;
            if (connector == null)
            {
                return(false);
            }

            RefreshIamTokenRequest req = new RefreshIamTokenRequest();

            req.Callback   = callback;
            req.HttpMethod = UnityWebRequest.kHttpVerbGET;
            req.Headers.Add("Content-type", "application/x-www-form-urlencoded");
            req.Headers.Add("Authorization", "Basic Yng6Yng=");
            req.OnResponse             = OnRefreshIamTokenResponse;
            req.DisableSslVerification = DisableSslVerification;
            req.Forms = new Dictionary <string, RESTConnector.Form>();
            req.Forms["grant_type"]    = new RESTConnector.Form("refresh_token");
            req.Forms["refresh_token"] = new RESTConnector.Form(_iamTokenData.RefreshToken);

            return(connector.Send(req));
        }
コード例 #2
0
ファイル: Credentials.cs プロジェクト: Marq91/ARImages
        /// <summary>
        /// Refresh an IAM token using a refresh token.
        /// </summary>
        /// <param name="successCallback">The success callback.</param>
        /// <param name="failCallback">The fail callback.</param>
        /// <param name="customData">Dictionary of custom data.</param>
        /// <returns></returns>
        public bool RefreshIamToken(SuccessCallback<IamTokenData> successCallback, FailCallback failCallback, Dictionary<string, object> customData = null)
        {
            if (successCallback == null)
                throw new ArgumentNullException("successCallback");
            if (failCallback == null)
                throw new ArgumentNullException("failCallback");

            RESTConnector connector = new RESTConnector();
            connector.URL = _iamUrl;
            if (connector == null)
                return false;

            RefreshIamTokenRequest req = new RefreshIamTokenRequest();
            req.SuccessCallback = successCallback;
            req.FailCallback = failCallback;
            req.Headers.Add("Content-type", "application/x-www-form-urlencoded");
            req.Headers.Add("Authorization", "Basic Yng6Yng=");
            req.OnResponse = OnRefreshIamTokenResponse;
            req.CustomData = customData == null ? new Dictionary<string, object>() : customData;
            if (req.CustomData.ContainsKey(Constants.String.CUSTOM_REQUEST_HEADERS))
            {
                foreach (KeyValuePair<string, string> kvp in req.CustomData[Constants.String.CUSTOM_REQUEST_HEADERS] as Dictionary<string, string>)
                {
                    req.Headers.Add(kvp.Key, kvp.Value);
                }
            }
            req.Forms = new Dictionary<string, RESTConnector.Form>();
            req.Forms["grant_type"] = new RESTConnector.Form("refresh_token");
            req.Forms["refresh_token"] = new RESTConnector.Form(_iamTokenData.RefreshToken);

            return connector.Send(req);
        }