Search code examples
ruby-on-rails-4powerbioffice365-restapi

Auto login in Power BI with REST API with cron task


I want auto login in Azure portal for access_token so that I can send data to Power BI dataset . From cron task in Rails App currently I am using

OAuth2::Client

and

OAuth2::AccessToken for generating token.

I add username, password , grant_type => 'password' and scope => 'openid' to OAuth2::Client but it is not working something is missing


Solution

  • I got this. Now I am using rest_client instead of Oauth2

    request =  RestClient.post( url,
          {
            :grant_type => 'password', 
              :scope => 'openid',
              :resource => 'https://analysis.windows.net/powerbi/api',
              :client_id => 'CLIENT_ID',
              :client_secret => 'CLIENT_SECRET',
              :username => 'USERNAME',
              :password => 'PASSWORD'
    
          })