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
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'
})
Related
How can I verify if a user is logged in on my services with AWS PHP SDK?
I am logging them with :
$result = $this->awsCognitoClient->adminInitiateAuth([
'AuthFlow' => 'ADMIN_NO_SRP_AUTH',
'ClientId' => $this->appClientID,
'UserPoolId' => $this->userPoolID,
'AuthParameters' => [
'USERNAME' => $userName,
'PASSWORD' => $password,
],
]);
That provides a session token. I want to send that token to another of my services and in that other service I want to check if the token is valid or not. How should I proceed?
Is this the best way or is there a better method to authenticate my user?
To solve this issue i created a singleton instance of an AWSAutWrapper and i share the accesstoken with other services.
I want to make the same function but in Python Django how can I do that
because I
want to make authentication for login using Oauth 2.0
public function callback(Request $request){
$response = Http::post('https://oauth.zid.sa' . '/oauth/token', [
'grant_type' =>'authorization_code',
'client_id' => 48,
'client_secret' => 'LsswUNyWTjyKT9AsXnpsv3FnG4glSNZQ5SM3YRnD',
'redirect_uri' => 'http://client.test/oauth/callback',
'code' => $request->code // grant code]);}
I'm trying to consume the OTRS generic interface. The rest service is created by the import functionallity. I found the files needed for import here Consuming OTRS TicketConnector from .NET apps
My problem is when I try to consume the interface for example with a curl command
curl http://<user>:<password>#<server-ip>:<port>/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket/<Ticket-id> -X GET
The result of the command is
{"Error":{"ErrorCode":"TicketGet.AuthFail","ErrorMessage":"TicketGet: Authorization failing!"}}
I tried every user/password combination that makes sense to me. I tried the otrs admin account, agent account, customer account, root account of the server, EVERYTHING! I can't find a information in the docs that states wich account type is needed.
Here are some information that are printed out by the webservice debugger
Communication sequence started
$VAR1 = {
'DOCUMENT_ROOT' => '/srv/www/htdocs',
'GATEWAY_INTERFACE' => 'CGI/1.1',
'HTTP_ACCEPT' => '*/*',
'HTTP_HOST' => '<server-name>',
'HTTP_USER_AGENT' => 'curl/7.39.0',
'MOD_PERL' => 'mod_perl/2.0.4',
'MOD_PERL_API_VERSION' => '2',
'PATH' => '/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/mit/bin:/usr/lib/mit/sbin',
'PATH_INFO' => '/Webservice/GenericTicketConnectorREST/Ticket/<ticket-id>',
'PATH_TRANSLATED' => '/srv/www/htdocs/Webservice/GenericTicketConnectorREST/Ticket/<ticket-id>',
'QUERY_STRING' => '',
'REMOTE_ADDR' => '<server-ip>',
'REMOTE_PORT' => '56065',
'REQUEST_METHOD' => 'GET',
'REQUEST_URI' => '/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket/<ticket-id>',
'SCRIPT_FILENAME' => '/opt/otrs/bin/cgi-bin/nph-genericinterface.pl',
'SCRIPT_NAME' => '/otrs/nph-genericinterface.pl',
'SERVER_ADDR' => '<server-ip>',
'SERVER_ADMIN' => '<admin-account>',
'SERVER_NAME' => '<server-name>',
'SERVER_PORT' => '80',
'SERVER_PROTOCOL' => 'HTTP/1.1',
'SERVER_SIGNATURE' => '<address>Apache/2.2.12 (Linux/SUSE) Server at <server-name> Port 80</address>
',
'SERVER_SOFTWARE' => 'Apache/2.2.12 (Linux/SUSE)'
};
Deteced operation TicketGet
No data provided
Incoming data before mapping
$VAR1 = {
'RequestMethod' => 'GET',
'TicketID' => '<ticket-id>'
};
TicketGet.AuthFail
TicketGet: Authorization failing!
Outgoing data before mapping
$VAR1 = {
'Error' => {
'ErrorCode' => 'TicketGet.AuthFail',
'ErrorMessage' => 'TicketGet: Authorization failing!'
}
};
Long story short: what type of authentication or user type otrs expects to access the generic interface?
In found my mistake. The way I passed the login credentials to the service was wrong.
In my case the user is a agent user.
Here is a working curl command for my service:
curl http://<server-ip>:<port>/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket/<ticket-id>?UserLogin=<username>\&Password=<password> -X GET
I'm using sendgrid and action mailer to send email from my rails app which is deployed on Heroku. My emails are being delivered but I'm not seeing any email activity in Sendgrid. The open tracking app is enabled.
I'm wondering if I've set up the app properly? I'm using the sendgrid-ruby gem and I've set
config.action_mailer.default_url_options = { host: ENV["DOMAIN"] }
and
ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'heroku.com',
:enable_starttls_auto => true
}
Is there anything else I need to do?
SendGrid was experiencing issues with their Email Activity yesterday (https://support.sendgrid.com/hc/en-us/articles/205074437-16-Mar-Email-Activity-Unavailable-)
I would contact their support team (support#sendgrid.com) and have them take a look.
I have integrated Sendgrid settings on a Rails 4 server. These settings work fine for development environment. But this is giving error on production environment.
Net::SMTPFatalError (550 Cannot receive from specified address <simmi#mydomain.com>: Unauthenticated senders not allowed)
config/initializers/email_setup.rb
ActionMailer::Base.smtp_settings = {
:address => "smtp.sendgrid.net",
:domain => DOMAIN,
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:authentication => "plain",
:enable_starttls_auto => true
}
config/initializers/devise.rb
config.mailer_sender = 'simmi#mydomain.com'
config/environments/production.rb
# Default URL
config.action_mailer.default_url_options = { host: 'mysite.mydomain.com' }
DOMAIN = 'mysite.mydomain.com'
According to sendgrid support team, this error comes when username or password are incorrect. I tried logging manually into the smtp server through telnet and it was working.
On my server commandline, I followed these steps:
telnet smtp.sendgrid.net 587
EHLO
AUTH LOGIN
Enter username in Base64
Enter password in Base64
Link to convert text into Base64 - http://www.opinionatedgeek.com/dotnet/tools/base64encode/
The ENV variables were somehow not working on my production environment. As a workaround, I tried adding the username and password directly and it worked.
I have also faced the same problem and fixed it by adding the following:
config/environment.rb
ActionMailer::Base.smtp_settings = {
:address => "smtp.sendgrid.net",
:domain => DOMAIN,
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:authentication => "plain",
:enable_starttls_auto => true
}
ActionMailer::Base.default_url_options = { host: 'mysite.mydomain.com' }
config/application.rb
ActionMailer::Base.delivery_method = :smtp
The letter_opener gem is very useful if you want to test sending emails in development mode.
If you want to overwrite the letter_opener, add the following configuration
config/environments/development.rb
ActionMailer::Base.delivery_method= :letter_opener
And also add the port under ActionMailer::Base.smtp_settings.
You are probably loading your environment variables after you are trying to initialize your mailer. You can do the initialization directly after loading your variables to be sure that they exist.
Set up a config file with your username and password variables:
# config/mailer.yml
production:
SENDGRID_USERNAME: 'username'
SENDGRID_PASSWORD: 'password'
Set up an initializer file:
# config/initializers/mailer.rb
if Rails.env.production?
config_path = File.expand_path(Rails.root.to_s + '/config/mailer.yml')
if File.exists? config_path
ENV.update YAML.load_file(config_path)[Rails.env]
end
ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => ENV["SENDGRID_USERNAME"],
:password => ENV["SENDGRID_PASSWORD"],
:domain => "yourdomain",
}
end
If your production environment is Heroku:
Login to your Heroku account and select the application. Under "Settings", click the "Reveal Config Vars" button. Enter in your sendgrid key and value pairs, then submit. Run: heroku restart.