コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request["code"] != null && !IsPostBack)
            {
                MYDIGIPASSAuth mydigipass = new MYDIGIPASSAuth();
                mydigipass.ApiTokenUrl = "https://sandbox.mydigipass.com/oauth/token";
                mydigipass.ApiAuthorizationUrl = "https://sandbox.mydigipass.com/oauth/user_data";
                mydigipass.ApiConnectUrl = "https://sandbox.mydigipass.com/api/uuids/connected";
                mydigipass.ApiDisconnectUrl = "https://sandbox.mydigipass.com/api/uuids/disconnected";
                mydigipass.ApiKey = "{client-id}";
                mydigipass.ApiSecret = "{client-secret}";
                mydigipass.ApiRedirectUri = "{redirect-uri}";
                mydigipass.ApiCode = Request["code"];

                mydigipass.AccessToken();

                if (mydigipass.HasToken)
                {
                    mydigipass.Authorization();

                    if (!String.IsNullOrEmpty(mydigipass.Email))
                    {
                        // Object stored in Session only for test purpose
                        HttpContext.Current.Session["MYDPSession"] = mydigipass;
                        HttpContext.Current.Session.Timeout = 20;

                        // Store UUID in your local database and then confirm user is connected to mydigipass.com
                        mydigipass.ConnectUser();

                        // Show the "ConnectedUsers" and "DisconnectUser" buttons for test purpose
                        _btnConnectedUsers.Enabled = true;
                        _btnDisconnectUser.Enabled = true;
                    }
                }
            }

            // Only for test purpose
            if ((MYDIGIPASSAuth)HttpContext.Current.Session["MYDPSession"] != null)
            {
                MYDIGIPASSAuth mydigipass = (MYDIGIPASSAuth)HttpContext.Current.Session["MYDPSession"];
                Response.Write(String.Format("<div>Successfully logged in with MYDIGIPASS.COM as: </div>", mydigipass.Email));
            }

            if (Request["error"] != null)
            {
                Response.Write(String.Format("<div>Error: {0}, {1}</div>", Request["error"], Request["error_description"]));
            }
        }
コード例 #2
0
 public void ConnectedUsers()
 {
     try
     {
         string response = this.Connected();
         if (response.Length > 0)
         {
             MYDIGIPASSAuth mydpResponse = (MYDIGIPASSAuth)JsonConvert.DeserializeObject(response, typeof(MYDIGIPASSAuth));
             this.Uuids = mydpResponse.Uuids;
         }
     }
     catch (Exception ex)
     {
         throw new System.Exception(ex.Message);
     }
 }
コード例 #3
0
 public void AccessToken()
 {
     try
     {
         string response = this.GetToken();
         if (response.Length > 0)
         {
             MYDIGIPASSAuth mydpResponse = (MYDIGIPASSAuth)JsonConvert.DeserializeObject(response, typeof(MYDIGIPASSAuth));
             this.Token = mydpResponse.Token;
         }
     }
     catch (Exception ex)
     {
         throw new System.Exception(ex.Message);
     }
 }
コード例 #4
0
 public void Authorization()
 {
     try
     {
         string response = this.Authenticate();
         if (response.Length > 0)
         {
             MYDIGIPASSAuth mydpResponse = (MYDIGIPASSAuth)JsonConvert.DeserializeObject(response, typeof(MYDIGIPASSAuth));
             this.Email = mydpResponse.Email;
             this.Uuid  = mydpResponse.Uuid;
             this.Data  = (Dictionary <string, string>)JsonConvert.DeserializeObject(response, typeof(Dictionary <string, string>));
         }
     }
     catch (Exception ex)
     {
         throw new System.Exception(ex.Message);
     }
 }