Exemplo n.º 1
0
Arquivo: PSN.cs Projeto: eai04191/OnPS
 private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
 {
     if (webBrowser1.Url.ToString().Contains("/mobile-success.jsp"))
     {
         Uri    uri               = new Uri(webBrowser1.Url.ToString());                    //Convert url to Uri class.
         string queryString       = uri.Query;                                              //Get uri query.
         NameValueCollection name = HttpUtility.ParseQueryString(queryString);              //Some computers may not respond here.
         code = name["targetUrl"];                                                          //Get Target URL.
         code = code.Replace("com.playstation.remoteplay.sceappcall://redirect?code=", ""); //Replace target url and get code.
         PSNAuthData AuthData = Platforms.PSN.AuthWithCode(code);                           //Authentication with code.
         IniModel.SetPSNRefreshToken(AuthData.refresh_token);                               //Get refresh token and save config file.
         this.Close();                                                                      //Close Form
     }
 }
Exemplo n.º 2
0
        public static PSNAuthData AuthWithCode(String code)
        {
            String  postData = "grant_type=authorization_code&code=" + code + "&redirect_uri=com.playstation.remoteplay.sceappcall://redirect&";
            JObject o        = null; //initialize variable!

            try
            {
                o = JObject.Parse(Network.HTTP_POST("https://auth.api.sonyentertainmentnetwork.com/2.0/oauth/token", postData));
            }
            catch (Exception)
            {
                return(null);
            }
            PSNAuthData AuthModel = new PSNAuthData();

            AuthModel.access_token  = o.GetValue("access_token").ToString();
            AuthModel.refresh_token = o.GetValue("refresh_token").ToString();
            return(AuthModel);
        }