title: How to correctly wait for oAuth ( Google Sheets ) in F#
body: <p>This bit of code is adapted from a C# version somewhere.</p>
  <p>I did actually get it running for a while by debugging through it and breakpointing on the line that starts with &quot;let! credential = &quot; and it would go to the website and I could authorise it and it would save the token etc and just run next time. How can I make it just wait until I have authorised it?</p>
  <pre><code>let getSheetService() = async {
      let Scopes:string[] = [|SheetsService.Scope.Spreadsheets|]
      let ApplicationName = &quot;R2hPl&quot;
      use stream = new FileStream(&quot;credentials.json&quot;, FileMode.Open, FileAccess.Read)
      // The file token.json stores the user's access and refresh tokens, and is created
      // automatically when the authorization flow completes for the first time.
      let credPath = &quot;c:\\certificates&quot;
      let secrets = GoogleClientSecrets.FromStream(stream).Secrets
      //let fileStore = new FileDataStore(credPath, true)
  
      // the following line is where I get 
      let! credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
          secrets,
          Scopes,
          &quot;user&quot;,
          CancellationToken.None,
          new FileDataStore(credPath, true)) |&gt; Async.AwaitTask
      Console.WriteLine(&quot;Credential file saved to: &quot; + credPath)
  
      // Create Google Sheets API service.
      let init = new BaseClientService.Initializer()
      init.HttpClientInitializer &lt;- credential
      init.ApplicationName &lt;- ApplicationName
  
      let service = new SheetsService(init)
      return service
  }
  </code></pre>