Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "error": {
- "errors": [
- {
- "domain": "androidpublisher",
- "reason": "permissionDenied",
- "message": "The current user has insufficient permissions to perform the requested operation."
- }
- ],
- "code": 401,
- "message": "The current user has insufficient permissions to perform the requested operation."
- }
- }
- scopes = ['https://www.googleapis.com/auth/androidpublisher']
- authorization = Google::Auth.get_application_default(scopes)
- uri = "https://www.googleapis.com/androidpublisher/v3/applications/#{ENV['ANDROID_PACKAGE_NAME']}/purchases/products/#{purchasable.purchase_uuid}/tokens/#{purchase_token}?access_token=#{authorization.fetch_access_token!['access_token']}"
- response = RestClient::Request.execute method: :get,
- url: uri,
- headers: {'Content-Type':'application/json'}
- file = File.read('config/google_key.json')
- values = JSON.parse(file)
- oauth = Signet::OAuth2::Client.new(
- issuer: values[:client_email]",
- audience: "https://www.googleapis.com/oauth2/v4/token",
- scope: "https://www.googleapis.com/auth/androidpublisher",
- client_id: values[:client_id],
- signing_key: OpenSSL::PKey::RSA.new(values[:private_key]),
- )
- jwt = oauth.to_jwt
- url = "https://www.googleapis.com/oauth2/v4/token"
- begin
- response = RestClient::Request.execute method: :post,
- url: url,
- headers: {'Content-Type': 'application/json'},
- payload: {
- grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
- assertion: jwt
- }
- result = JSON.parse response.body
- rescue => e
- puts e.response.to_str
- result = JSON.parse(e.response.to_s)
- end
Add Comment
Please, Sign In to add comment