{"text_format":"1","workbook":"xlsx","n_sheets":2,"sheets":["Documentation","Parameters"],"not_rendered":{"charts":0,"images":2,"macros":1,"external_links":0,"defined_names":24,"comments":0,"pivot_tables":0},"unopened":[],"bounds":{"document_bytes":16777216,"sheet_cells":100000,"rows_first":2000,"rows_last":500,"rows_between":2000,"halvings":0,"cell_chars":16384,"cell_head_chars":4096},"cells_cut":0,"cells_raw":0,"read":"whole","date_system":"1900"}

{"sheet":"Documentation","index":0,"n_rows":61,"n_cols":9,"rows_kept":61,"cut":false,"hidden":false,"merged":[]}
["HMRC Making Tax Digital - oAuth2 tests",null,null,null,null,null,null,null,"oAuth2 Flow, example for Google"]
[" Author    : Patrick O'Beirne (@ExcelAnalytics) "]
["              Systems Modelling http://www.sysmod.com  <pob@sysmod.com>"]
["'              http://ie.linkedin.com/in/patrickobeirne"]
["' Source    : download from sysmod.wordpress.com"]
["'https://opensource.org/licenses/mit-license.php"]
["'Copyright 2019 Patrick O'Beirne"]
[]
["Sources"]
[null,"https://www.gov.uk/government/news/hmrc-publishes-more-information-on-making-tax-digital"]
[null,"HMRC publishes more information on Making Tax Digital"]
[null,"https://developer.service.hmrc.gov.uk/api-documentation"]
[null,"Navigation menu at the top offers: Documentation,  Applications,  Support"]
[null,"https://developer.service.hmrc.gov.uk/api-documentation/docs/using-the-hub"]
[null,"Getting Started"]
[null,"http://ramblings.mcpher.com/Home/excelquirks/googleoauth2"]
[null,"Bruce McPherson posts VBA code for an oAuth2 class "]
[]
["Work through the Getting Started tasks"]
[null,"https://developer.service.hmrc.gov.uk/api-documentation/docs/authorisation"]
[null,"Learn about which Authorisation level you need :  APIs have 3 types of endpoint."]
[]
["Checklist of things to do on HMRC website in order to complete these exercises"]
[]
[null,"1. Read Getting Started"]
[]
[null,"2. Register for an account and sign in"]
[]
[null,"3. Read the Testing instructions"]
[]
[null,"4. Add an application"]
[]
[null,"5. Subscribe to the APIs you want.  ",null,null,null,"Links to test subs in VBA"]
[null,null,"Hello World API",null,null,"Open Endpoint"]
[null,null,"Create Test User",null,null,"App Endpoint"]
[null,null,"Individual PAYE Test Support API",null,null,"User Endpoint"]
[null,null,"Individual Benefits"]
[]
[null,"6. Get Sandbox credentials from the Application page"]
[null,"   and paste into the fields on the Parameters sheet",null,null,null,"Application Parameters"]
[null,"The parameters ending in _uri are those currently defined by the HMRC API."]
[]
[null,"7. To test user-restricted endpoints, you need to create one or more test users."]
[null,"The Create Test User Service (see picture on the right) does it manually."]
[null,"There is an API for it, not used here."]
[null,"https://developer.service.hmrc.gov.uk/api-documentation/docs/authorisation/user-restricted-endpoints"]
[null,"In this demo, an individual user is tested.",null,null,null,"User Endpoint"]
[null,"Copy the generated data into the Parameters sheet "]
[null,"at \"Generated Individual\""]
[]
[]
[null,"When you exercise the User-authenticated end point, you get a dialog with text like this:"]
[null," GOV.UK  "]
[null,"HM Revenue & Customs"]
[null,"Authority to interact with HMRC on your behalf"]
[null,{"$f":"application_name &\" needs permission to interact with HMRC on your behalf. To grant this authority, you'll need to: \"","v":"<YOUR APP NAME> needs permission to interact with HMRC on your behalf. To grant this authority, you'll need to: "}]
[null,"1.Sign in to your Government Gateway account.",null,null,null,null,null," "]
[null,"2.Enter the 6 digit access code we'll send to your mobile phone, landline or other device."]
[null,"3.You might need to confirm who you are by answering some security questions on, for example, your passport, P60 or other documents."]
[null,"4.Grant authority to interact with HMRC on your behalf."]
[null,"This authority will last for 18 months. You can remove this authority at any time."]

{"sheet":"Parameters","index":1,"n_rows":40,"n_cols":3,"rows_kept":40,"cut":false,"hidden":false,"merged":[]}
["TEST DATA","This should be stored in the Registry, or encrypted. This demo uses named ranges on this sheet."]
[]
["application_name","<YOUR APP NAME>"]
["application_id","<YOUR APP ID>",{"$f":"\"https://developer.service.hmrc.gov.uk/developer/applications/\"&application_id&\"/details\"","v":"https://developer.service.hmrc.gov.uk/developer/applications/<YOUR APP ID>/details"}]
["client_id","<YOUR CLIENT ID>",{"$f":"\"https://developer.service.hmrc.gov.uk/developer/applications/\"&application_id&\"/credentials\"","v":"https://developer.service.hmrc.gov.uk/developer/applications/<YOUR APP ID>/credentials"}]
["client_secret","<YOUR CLIENT SECRET>","Use these credentials to test against sandbox APIs."]
["server_token","<YOUR SERVER TOKEN>"]
["Sandbox base URL","https://test-api.service.hmrc.gov.uk"]
[]
["redirect_uri","urn:ietf:wg:oauth:2.0:oob:auto","Used to launch an IE window from this application so that the user can grant authorization to this application"]
[null,null,"https://developer.service.hmrc.gov.uk/api-documentation/docs/authorisation/user-restricted-endpoints#installed-applications"]
[null,null,"Without :auto the dialog ends with a message to the user to copy and paste the code into the application."]
[]
["authorize_uri","/oauth/authorize","Step 1: The initial url for authentication"]
["token_uri","/oauth/token","Step 2: The initial POST body to get the initial Token and refresh token"]
[]
[null,"This token data should also be stored elsewhere, this is just for visibility in testing"]
["test_user_id",{"$f":"individual_user_id","v":"000000000000"},"Example of individual test user, see below"]
["application_scope","hello","This sets what the application can access"]
["access_token",null,"Valid for 4 hours"]
["refresh_token",null,"Needed after 4 hours"]
["expires_at","2019-04-03T17:00:30","should be now()+4 hours"]
[]
[]
["Generated individual"]
["Use these credentials in the OAuth Authorize flow to generate an OAuth access token for this individual."]
["individual_user_id","000000000000","User ID for an individual"]
["individual_password","(not required in this app, only by the user when authenticating)","Password"]
["individual_self assessment_utr",null,"Self Assessment UTR (SA_UTR)"]
["individual_nino",null,"National Insurance Number (NINO)"]
[]
[]
["Generated organisation"]
["Use these credentials in the OAuth Authorize flow to generate an OAuth access token for this organisation."]
["org_id",null,"User ID for an organisation"]
["org_password",null,"Password"]
["org_self_assessment_utr",null,"Self Assessment UTR"]
["org_corporation_tax_utr",null,"Corporation Tax UTR"]
["org_employer_ref",null,"Employer Reference"]
["org_vat_registration_number",null,"VAT Registration Number"]