Clojure spotify user authentication - api

I have some stuff working with the spotify API for a mini project, but can't understand / get an implementation of the user login and authentication in Clojure.
I have the following code snippet to try and open the user auth:
(ns app-fig.spotify
(:require [clj-http.client :as client]))
(defn auth-user
[client-id]
(client/get "https://accounts.spotify.com/authorize" {:query-params
{"client_id" client-id
"response_type" "code"
"redirect_url" "http://localhost:3449/callback"
"scope" "playlist-modify-private"}}))
I get the following error in calva:
; Execution error (MalformedCookieException) at org.apache.http.impl.cookie.BasicExpiresHandler/parse (BasicExpiresHandler.java:64).
; Invalid 'expires' attribute: 2022-10-9 08:50:33.742
and the following warning in the terminal:
WARNING: Invalid cookie header: "set-cookie: __Host-sp_csrf_sid=360afea54e9aeacfa17925dcf1b3b2aae0ba4734b9b838751a450a6f32458da5; Path=/; HttpOnly; Secure; Expires=2022-10-9 08:32:57.829; Max-Age=3600; SameSite=Lax". Invalid 'expires' attribute: 2022-10-9 08:32:57.829
The spotify auth workflow is listed here.
Any assistance would be wonderful!

Related

Errors on login with paypal with pow assent

I have trouble using the paypal api with my test app
I am using pow_assent and using my own strategy... it sends me to the paypal page and everything works great until im redirected back to my site, it shows: "Something went wrong, and you couldn't be signed in. Please try again." and it shows this error on terminal
[error] Strategy failed with error: %Assent.RequestError{error: :invalid_server_response, message: "Server responded with status: 401\n\nHeaders:\ncache-control: max-age=0, no-cache, no-store, must-revalidate\nconnection: keep-alive\ndate: Sun, 01 Aug 2021 02:44:29 GMT\nvia: 1.1 varnish, 1.1 varnish\naccept-ranges: bytes\nserver: nginx/1.14.0 (Ubuntu)\ncontent-length: 244\ncontent-type: application/json\npaypal-debug-id: 53f3a821ee6e1\nstrict-transport-security: max-age=31536000; includeSubDomains\nedge-control: max-age=0\nx-served-by: cache-dfw18678-DFW, cache-pwk4959-PWK\nx-cache: MISS, MISS\nx-cache-hits: 0, 0\nx-timer: S1627785869.405094,VS0,VE164\n\nBody:\n%{\"links\" => [%{\"href\" => \"https://developer.paypal.com/docs/api/overview/#error\", \"rel\" => \"information_link\"}], \"message\" => \"Authentication failed due to invalid authentication credentials or a missing Authorization header.\", \"name\" => \"AUTHENTICATION_FAILURE\"}\n"}
I have tried to fix this... but haven't figured it out yet. Would appreciate some help

Socket Hang Up while trying to hit APIs hosted on AWS via Postman

I am trying to test an API hosted using AWS API Gateway and always getting following error:
Error: socket hang up
Request Headers
clientId: system
Authorization: //Correct Auth Token
User-Agent: PostmanRuntime/7.26.8
Accept: */*
Host: //API Host URL
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
However, when I pass in an invalid Auth Token (like TEST), I actually receive a 403 error as expected. I can also see logs in CloudWatch confirming the call reached the authorizer.
CloudWatch Logs
The same API works for other people perfectly fine.
I have tried almost every resolution I found online related to this issue like I turned off 'SSL Certificate Verification' in Postman and kept proxy settings same as my colleagues. Tried to hit the API after disconnecting VPN as well but nothing worked for me.
Could anyone please help me with this.
Thanks in advance.

Login credentials for password reset not working in Laravel 7

I tested my credentials with https://www.smtper.net/ and they work flawlessly for port 25 (without encryption) and port 465 (with encryption). Maybe there is an error in my Laravel config files:
.env:
MAIL_DRIVER=smtp
MAIL_HOST=###.netcup.net
MAIL_PORT=25
MAIL_USERNAME=me#mydomain.de
MAIL_PASSWORD=#########
MAIL_FROM_ADDRESS=me#mydomain.de
MAIL_FROM_NAME="me"
MAIL_ENCRYPTION=null
I also tried
MAIL_DRIVER=smtp
MAIL_HOST=###.netcup.net
MAIL_PORT=465
MAIL_USERNAME=me#mydomain.de
MAIL_PASSWORD=#########
MAIL_FROM_ADDRESS=me#mydomain.de
MAIL_FROM_NAME="me"
MAIL_ENCRYPTION=ssl
config/mail.php:
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', '###.netcup.net'),
'port' => env('MAIL_PORT', 25),
'encryption' => env('MAIL_ENCRYPTION', 'null'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'auth_mode' => null,
],
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'me#mydomain.de'),
'name' => env('MAIL_FROM_NAME', 'me'),
],
Both port 25 and 465 requests bring this error in Laravel:
[2020-05-11 12:56:35] local.ERROR: Failed to authenticate on SMTP server with username "me#mydomain.de" using 3 possible authenticators. Authenticator CRAM-MD5 returned Expected response code 235 but got code "535", with message "535 5.7.8 Error: authentication failed: authentication failure
". Authenticator LOGIN returned Expected response code 235 but got code "535", with message "535 5.7.8 Error: authentication failed: authentication failure
". Authenticator PLAIN returned Expected response code 235 but got code "535", with message "535 5.7.8 Error: authentication failed: authentication failure
". {"exception":"[object] (Swift_TransportException(code: 0): Failed to authenticate on SMTP server with username \"me#mydomain.de\" using 3 possible authenticators. Authenticator CRAM-MD5 returned Expected response code 235 but got code \"535\", with message \"535 5.7.8 Error: authentication failed: authentication failure
\". Authenticator LOGIN returned Expected response code 235 but got code \"535\", with message \"535 5.7.8 Error: authentication failed: authentication failure
\". Authenticator PLAIN returned Expected response code 235 but got code \"535\", with message \"535 5.7.8 Error: authentication failed: authentication failure
\". at C:\\wamp64\\www\\vanilli\\vendor\\swiftmailer\\swiftmailer\\lib\\classes\\Swift\\Transport\\Esmtp\\AuthHandler.php:191)
This issue occured several times here but none of the answers did work. This happens in a vanilla installation of Laravel 7, nothing has been modified except these config files. Anyone has an idea? Thanks.
You have to configure your email address
Less Secure
I think you mean "Allow less secure apps."

Datastore API always returning "dsid: Missing Value" error

I'm trying to follow the datastore API tutorial and this simple request (sent via Fiddler):
POST https://api.dropbox.com/1/datastores/get_or_create_datastore HTTP/1.1
User-Agent: Fiddler
Host: api.dropbox.com
Content-Length: 12
Authorization: Bearer [snipped]
dsid=default
always results in this error response:
HTTP/1.1 400 Bad Request
{"error": {"dsid": "Missing value"}}
The access token was created from the developer app console, and my test app has full dropbox permissions. Running the list_datastores API call succeeds and reports that I do have one datastore with a dsid of default.
I think you'll need a header of Content-Type: application/x-www-form-url-encoded, since you're sending form-encoded parameters.

Jenkins: 'Trigger Builds Remotely' with ?token not working when Matrix Authorization Strategy is used

I'm having a problem with triggering builds in Jenkins with authentication enabled and wondering if anyone has ideas.
I have Global Security configured to use LDAP with "Project-based Matrix Authorization Strategy" enabled. The "Anonymous" user has the "Job > Build" privilege, and no other privileges (in particular, the "Anonymous" user does NOT have "Overall > Read" privilege, since I don't want everyone to be able to view the list of jobs and other general information).
I want an automated script to be able to trigger a build using the "Trigger Builds Remotely" feature, where I specify a ?token=[token] value in the URL and the standard authentication should be bypassed, as long as the [token] value matches the one I set in the job's Configure page. The goal is to NOT need to provide a regular username/password in the request but simply provide the token for this specific job.
The documentation seems to indicate this should work:
https://wiki.jenkins-ci.org/display/JENKINS/Quick+and+Simple+Security
So specifically, I am expecting this HTTP request to work:
curl -i https://jenkinsHost/job/ProjectName/build?token=test
But I get:
[~]$ curl -i https://jenkinsHost/job/ProjectName/build?token=test
HTTP/1.1 403 Forbidden
Date: Sat, 27 Apr 2013 23:17:03 GMT
Server: Winstone Servlet Engine v0.9.10
Content-Type: text/html;charset=UTF-8
Content-Length: 629
X-Powered-By: Servlet/2.5 (Winstone/0.9.10)
Set-Cookie: JSESSIONID.e9bc4765=e1f0a30b9f04b3740bae527a7822b2d5; Path=/; HttpOnly
Connection: close
<html><head><meta http-equiv='refresh' content='1;url=/login?from=%2Fjob%2FProjectName%2Fbuild%3Ftoken%3Dtest'/>
<script>
window.location.replace('/login?from=%2Fjob%2FProjectName%2Fbuild%3Ftoken%3Dtest');</script>
</head>
<body style='background-color:white; color:white;'>
Authentication required
</body></html>
When I DO use API authentication, the request works:
curl --username "test_user:API_KEY" https://hostname/job/ProjectName/build?token=test
But again, according to the documentation I think it is supposed to bypass the global authentication if ?token is present and matches the project token I configure. Why is this not working? What other information/logs can I provide?
There's a new plugin that allows you to do that even when Jenkins prohibits anonymous read access:
Build Token Root Plugin
Use:
$ curl 'http://jenkins/buildByToken/build?job=jobname&token=mytoken'
Scheduled.
Likewise with buildWithParameters.
Example for using the "Build Authorization Token Root" plugin with POST:
wget --post-data="job=MyJob&token=SECRET&MyParameter=hello" http://servername/jenkins/buildByToken/buildWithParameters
note that "Trigger Builds Remotely" must be activated for this job (with authorization token "SECRET")