File tree 2 files changed +16
-5
lines changed
2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ Note: For changes to the API, see https://shopify.dev/changelog?filter=api
4
4
5
5
## Unreleased
6
6
- [ #1237 ] ( https://github.com/Shopify/shopify-api-ruby/pull/1237 ) Skip mandatory webhook topic registration/unregistrations
7
+ - [ ] ( ) Update ` OAuth.validate_auth_callback ` to use ` ShopifyApi::Clients::HttpClient ` .
7
8
8
9
## 13.2.0
9
10
Original file line number Diff line number Diff line change @@ -70,15 +70,25 @@ def validate_auth_callback(cookies:, auth_query:)
70
70
raise Errors ::InvalidOauthError ,
71
71
"Invalid state in OAuth callback." unless state == auth_query . state
72
72
73
- # TODO: replace this call with the HTTP client once it is built
73
+ null_session = Auth :: Session . new ( shop : auth_query . shop )
74
74
body = { client_id : Context . api_key , client_secret : Context . api_secret_key , code : auth_query . code }
75
- response = HTTParty . post ( "https://#{ auth_query . shop } /admin/oauth/access_token" , body : body )
76
- unless response . ok?
75
+
76
+ client = Clients ::HttpClient . new ( session : null_session , base_path : "/admin/oauth" )
77
+ response = begin
78
+ client . request (
79
+ Clients ::HttpRequest . new (
80
+ http_method : :post ,
81
+ path : "access_token" ,
82
+ body : body ,
83
+ body_type : "application/json" ,
84
+ ) ,
85
+ )
86
+ rescue ShopifyAPI ::Errors ::HttpResponseError => e
77
87
raise Errors ::RequestAccessTokenError ,
78
- "Cannot complete OAuth process. Received a #{ response . code } error while requesting access token."
88
+ "Cannot complete OAuth process. Received a #{ e . code } error while requesting access token."
79
89
end
80
- session_params = response . to_h
81
90
91
+ session_params = T . cast ( response . body , T ::Hash [ String , T . untyped ] ) . to_h
82
92
session = create_new_session ( session_params , auth_query . shop )
83
93
84
94
cookie = if Context . embedded?
You can’t perform that action at this time.
0 commit comments