janhommes / o.js

o.js - client side oData lib.

Home Page:https://janhommes.github.io/o.js/example/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Example of how to include credentials

Manaf-Ibrahim opened this issue · comments

Hi,

I am wondering if there was any examples of how to override the default config value for credentials? The endpoint I am querying requires a username and password.

Any help with this would be greatly appreciated.

@Manaf-Ibrahim it depends on the authentication mechanism used. Basic auth is simple:

o('someUrl', { 
  headers:
    { 
      'Authorization': `Basic ${btoa('username:password')}`
    } 
});

Others are more complex, as you might need to get an access token first or they are using a cookie for authentication.