Exemple #1
0
 /// <summary>
 /// Performs OAuth2 authentication, given the browser uri 
 /// </summary>
 /// <param name="uri">Current browser uri</param>
 /// <exception>AccessRefusedException when user clicks `Cancel` on access confirmation page</exception>
 /// <returns></returns>
 public async Task<bool> Authenticate(Uri uri) {
   if (uri.Host == "localhost") {
     var tokenParams = auth.BuildTokenParams(uri);
     var response = await connection.PostStringAsync(auth.BuildTokenUri(), tokenParams);
     // TODO: move json stuff somewhere else
     token = JObject.Parse(response)["access_token"].ToString();
     if (String.IsNullOrEmpty(token)) {
       return false;
     } else {
       current = this;
       return true;
     }
   }
   else return false;
 }
Exemple #2
0
 private void StartAuthentication() {
   api = new Api(Env.ApiClientId, Env.ApiClientSecret);
   Browser.Navigate(api.AuthenticateUri);
 }