Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Mohammad Dwikurnia Apriadi
Diskuy-Backend
Commits
7d8c2f24
Commit
7d8c2f24
authored
Feb 22, 2021
by
Muhammad Rafif Elfazri
Browse files
Add proxy url ENV Variables
parent
2750df8b
Changes
2
Hide whitespace changes
Inline
Side-by-side
config/releases.exs
View file @
7d8c2f24
...
...
@@ -42,6 +42,9 @@ config :diskuy, DiskuyWeb.Auth.Guardian,
issuer:
"diskuy"
,
secret_key:
guardian_secret_key_base
config
:diskuy
,
DiskuyWeb
.
Auth
.
GoogleAuth
,
proxy:
System
.
get_env
(
"PROXY"
)
# ## Using releases (Elixir v1.9+)
#
# If you are doing OTP releases, you need to instruct Phoenix
...
...
lib/diskuy_web/auth/google_auth.ex
View file @
7d8c2f24
...
...
@@ -5,14 +5,23 @@ defmodule DiskuyWeb.Auth.GoogleAuth do
@google_user_profile
"https://www.googleapis.com/oauth2/v3/userinfo"
@spec
get_user_profile
(
String
.
t
)
::
String
.
t
def
get_user_profile
(
token
)
do
"
#{
@google_user_profile
}
?access_token=
#{
token
}
"
|>
HTTPoison
.
get
()
|>
handle_get_proxy
()
|>
parse_body_response
()
end
@spec
parse_body_response
({
atom
,
String
.
t
})
::
String
.
t
defp
handle_get_proxy
(
url
)
do
case
Application
.
get_env
(
:diskuy
,
:proxy
)
do
nil
->
HTTPoison
.
get
(
url
)
proxy
->
HTTPoison
.
get
(
url
,
[],
[{
:proxy
,
proxy
}])
end
end
def
parse_body_response
({
:error
,
err
}),
do
:
{
:error
,
err
}
def
parse_body_response
({
:ok
,
response
})
do
body
=
Map
.
get
(
response
,
:body
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment