Module: Fortnox
- Extended by:
- RestEasy
- Defined in:
- lib/fortnox.rb,
lib/fortnox/types.rb,
lib/fortnox/struct.rb,
lib/fortnox/version.rb,
lib/fortnox/resource.rb,
lib/fortnox/collection.rb,
lib/fortnox/mappers/date.rb,
lib/fortnox/mappers/struct.rb,
lib/fortnox/resources/unit.rb,
lib/fortnox/resources/label.rb,
lib/fortnox/resources/order.rb,
lib/fortnox/auth/thread_local.rb,
lib/fortnox/mappers/order_row.rb,
lib/fortnox/resources/article.rb,
lib/fortnox/resources/invoice.rb,
lib/fortnox/resources/project.rb,
lib/fortnox/structs/order_row.rb,
lib/fortnox/resources/customer.rb,
lib/fortnox/resources/document.rb,
lib/fortnox/mappers/invoice_row.rb,
lib/fortnox/structs/invoice_row.rb,
lib/fortnox/mappers/country_code.rb,
lib/fortnox/mappers/document_row.rb,
lib/fortnox/mappers/struct_array.rb,
lib/fortnox/structs/document_row.rb,
lib/fortnox/mappers/edi_information.rb,
lib/fortnox/structs/edi_information.rb,
lib/fortnox/mappers/label_references.rb,
lib/fortnox/mappers/email_information.rb,
lib/fortnox/structs/default_templates.rb,
lib/fortnox/structs/email_information.rb,
lib/fortnox/resources/terms_of_payment.rb,
lib/fortnox/structs/default_delivery_types.rb
Defined Under Namespace
Modules: Auth, Mappers, Structs, Types
Classes: Article, AttributeError, Collection, ConstraintError, Customer, Document, Error, Invoice, Label, MissingAccessToken, MissingAttributeError, Order, Project, RequestError, Resource, Struct, TermsOfPayment, Unit
Constant Summary
collapse
- OAUTH_TOKEN_URL =
'https://apps.fortnox.se/oauth-v1/token'
- VERSION =
'1.0.0.rc1'
Class Method Summary
collapse
Class Method Details
.access_token=(token) ⇒ Object
.request_access_token(client_id:, client_secret:, tenant_id:, scopes: nil) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/fortnox.rb', line 67
def request_access_token(client_id:, client_secret:, tenant_id:, scopes: nil)
response = token_request(client_id, client_secret, tenant_id, scopes)
parsed = JSON.parse(response.body)
unless response.success?
error = parsed['error_description'] || parsed['error'] || response.body
raise RequestError, "Token request failed (#{response.status}): #{error}"
end
parsed['access_token']
end
|