public void Execute(NestClient temp) { // A request code you can verify later. string AUTH_TOKEN_REQUEST_CODE = "123"; // Set the configuration values. var nestConfig = new NestConfig( clientId: "client-id", clientSecret: "client-secret", redirectUrl: "https://redirect-url", state: AUTH_TOKEN_REQUEST_CODE); var oauth2 = new NestOauth2(nestConfig); // Launch the auth flow if you don't already have a token. var requestUrl = oauth2.GetClientCodeUrl(); //TODO: GET requestUrl in webbrowser. different way on different platform // If authorized, you can receive resulting url that contains the authorization code. string resultingUrl = null; var authorizationCode = oauth2.ParseAuthorizationCode(resultingUrl); //receive the token var token = oauth2.CreateToken(authorizationCode); // Save the token to a safe place here so it can be re-used later. }
public TokenGetter(NestConfig nestConfig) { this.oauth2 = new NestOauth2(nestConfig); this.nestConfig = nestConfig; this.nestToken = null; }