Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
server
Manage
Activity
Members
Labels
Plan
Issues
25
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
"git@gitlab.coko.foundation:xpub/xpub-faraday.git" did not exist on "f4468a212efe841f7803bce617cf16e192cf3f3b"
Show more breadcrumbs
cokoapps
server
Commits
73567b57
Commit
73567b57
authored
2 years ago
by
Alexandros Georgantas
Browse files
Options
Downloads
Patches
Plain Diff
refactor(server): make service url follow same structure as server url
parent
af986db8
No related branches found
No related tags found
3 merge requests
!52
Docx
,
!42
refactor(server): make service url follow same structure as server url
,
!17
Graphql api
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/utils/getAccessToken.js
+17
-6
17 additions, 6 deletions
src/utils/getAccessToken.js
with
17 additions
and
6 deletions
src/utils/getAccessToken.js
+
17
−
6
View file @
73567b57
...
...
@@ -18,15 +18,26 @@ const getAccessToken = async (serviceName, renew = false) => {
throw
new
Error
(
`service
${
serviceName
}
configuration is undefined `
)
}
const
{
clientId
,
clientSecret
,
port
,
protocol
,
host
}
=
service
const
{
clientId
,
clientSecret
,
url
}
=
service
if
(
!
clientId
)
{
throw
new
Error
(
`service
${
serviceName
}
clientId is undefined `
)
}
if
(
!
clientSecret
)
{
throw
new
Error
(
`service
${
serviceName
}
clientSecret is undefined `
)
}
if
(
!
url
)
{
throw
new
Error
(
`service
${
serviceName
}
url is undefined `
)
}
const
buff
=
Buffer
.
from
(
`
${
clientId
}
:
${
clientSecret
}
`
,
'
utf8
'
)
const
base64data
=
buff
.
toString
(
'
base64
'
)
const
serviceURL
=
`
${
protocol
}
://
${
host
}${
port
?
`:
${
port
}
`
:
''
}
`
const
serviceHealthCheck
=
await
axios
({
method
:
'
get
'
,
url
:
`
${
serviceURL
}
/healthcheck`
,
url
:
`
${
url
}
/healthcheck`
,
})
const
{
data
:
healthCheckData
}
=
serviceHealthCheck
...
...
@@ -43,7 +54,7 @@ const getAccessToken = async (serviceName, renew = false) => {
if
(
!
foundServiceCredential
)
{
const
{
data
}
=
await
axios
({
method
:
'
post
'
,
url
:
`
${
serviceURL
}
/api/auth`
,
url
:
`
${
url
}
/api/auth`
,
headers
:
{
authorization
:
`Basic
${
base64data
}
`
},
})
...
...
@@ -60,7 +71,7 @@ const getAccessToken = async (serviceName, renew = false) => {
if
(
!
accessToken
||
renew
)
{
const
{
data
}
=
await
axios
({
method
:
'
post
'
,
url
:
`
${
serviceURL
}
/api/auth`
,
url
:
`
${
url
}
/api/auth`
,
headers
:
{
authorization
:
`Basic
${
base64data
}
`
},
})
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment